|
|
|
@ -83,29 +83,33 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescr
|
|
|
|
return MakeResult<VirtualDir>(std::move(out));
|
|
|
|
return MakeResult<VirtualDir>(std::move(out));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id,
|
|
|
|
VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) {
|
|
|
|
u128 user_id, u64 save_id) {
|
|
|
|
return dir->GetDirectoryRelative(GetSaveDataSpaceIdPath(space));
|
|
|
|
// According to switchbrew, if a save is of type SaveData and the title id field is 0, it should
|
|
|
|
}
|
|
|
|
// be interpreted as the title id of the current process.
|
|
|
|
|
|
|
|
if (type == SaveDataType::SaveData && title_id == 0)
|
|
|
|
|
|
|
|
title_id = Core::CurrentProcess()->GetTitleID();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string out;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) {
|
|
|
|
switch (space) {
|
|
|
|
switch (space) {
|
|
|
|
case SaveDataSpaceId::NandSystem:
|
|
|
|
case SaveDataSpaceId::NandSystem:
|
|
|
|
out = "/system/";
|
|
|
|
return "/system/";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SaveDataSpaceId::NandUser:
|
|
|
|
case SaveDataSpaceId::NandUser:
|
|
|
|
out = "/user/";
|
|
|
|
return "/user/";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SaveDataSpaceId::TemporaryStorage:
|
|
|
|
case SaveDataSpaceId::TemporaryStorage:
|
|
|
|
out = "/temp/";
|
|
|
|
return "/temp/";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space));
|
|
|
|
ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space));
|
|
|
|
|
|
|
|
return "/unrecognized/"; ///< To prevent corruption when ignoring asserts.
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id,
|
|
|
|
|
|
|
|
u128 user_id, u64 save_id) {
|
|
|
|
|
|
|
|
// According to switchbrew, if a save is of type SaveData and the title id field is 0, it should
|
|
|
|
|
|
|
|
// be interpreted as the title id of the current process.
|
|
|
|
|
|
|
|
if (type == SaveDataType::SaveData && title_id == 0)
|
|
|
|
|
|
|
|
title_id = Core::CurrentProcess()->GetTitleID();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string out = GetSaveDataSpaceIdPath(space);
|
|
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
switch (type) {
|
|
|
|
case SaveDataType::SystemSaveData:
|
|
|
|
case SaveDataType::SystemSaveData:
|
|
|
|
return fmt::format("{}save/{:016X}/{:016X}{:016X}", out, save_id, user_id[1], user_id[0]);
|
|
|
|
return fmt::format("{}save/{:016X}/{:016X}{:016X}", out, save_id, user_id[1], user_id[0]);
|
|
|
|
|