diff options
| author | 2018-10-28 14:56:43 -0400 | |
|---|---|---|
| committer | 2018-10-29 13:54:38 -0400 | |
| commit | df264d2ccb39a4d7ffd4efd3158e66db3aa6952a (patch) | |
| tree | c934e298ce1931b90045ea18eee68551b7f744c7 /src/core/file_sys | |
| parent | loader/nro: Call RegisterRomFS from Load (diff) | |
| download | yuzu-df264d2ccb39a4d7ffd4efd3158e66db3aa6952a.tar.gz yuzu-df264d2ccb39a4d7ffd4efd3158e66db3aa6952a.tar.xz yuzu-df264d2ccb39a4d7ffd4efd3158e66db3aa6952a.zip | |
savedata_factory: Expose accessors for SaveDataSpace
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 32 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.h | 3 |
2 files changed, 21 insertions, 14 deletions
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index ef1aaebbb..1ec54c78f 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -83,28 +83,32 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescr | |||
| 83 | return MakeResult<VirtualDir>(std::move(out)); | 83 | return MakeResult<VirtualDir>(std::move(out)); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, | 86 | VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) { |
| 87 | u128 user_id, u64 save_id) { | 87 | return dir->GetDirectoryRelative(GetSaveDataSpaceIdPath(space)); |
| 88 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should | 88 | } |
| 89 | // be interpreted as the title id of the current process. | ||
| 90 | if (type == SaveDataType::SaveData && title_id == 0) | ||
| 91 | title_id = Core::CurrentProcess()->GetTitleID(); | ||
| 92 | |||
| 93 | std::string out; | ||
| 94 | 89 | ||
| 90 | std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) { | ||
| 95 | switch (space) { | 91 | switch (space) { |
| 96 | case SaveDataSpaceId::NandSystem: | 92 | case SaveDataSpaceId::NandSystem: |
| 97 | out = "/system/"; | 93 | return "/system/"; |
| 98 | break; | ||
| 99 | case SaveDataSpaceId::NandUser: | 94 | case SaveDataSpaceId::NandUser: |
| 100 | out = "/user/"; | 95 | return "/user/"; |
| 101 | break; | ||
| 102 | case SaveDataSpaceId::TemporaryStorage: | 96 | case SaveDataSpaceId::TemporaryStorage: |
| 103 | out = "/temp/"; | 97 | return "/temp/"; |
| 104 | break; | ||
| 105 | default: | 98 | default: |
| 106 | ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space)); | 99 | ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space)); |
| 100 | return "/unrecognized/"; ///< To prevent corruption when ignoring asserts. | ||
| 107 | } | 101 | } |
| 102 | } | ||
| 103 | |||
| 104 | std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, | ||
| 105 | u128 user_id, u64 save_id) { | ||
| 106 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should | ||
| 107 | // be interpreted as the title id of the current process. | ||
| 108 | if (type == SaveDataType::SaveData && title_id == 0) | ||
| 109 | title_id = Core::CurrentProcess()->GetTitleID(); | ||
| 110 | |||
| 111 | std::string out = GetSaveDataSpaceIdPath(space); | ||
| 108 | 112 | ||
| 109 | switch (type) { | 113 | switch (type) { |
| 110 | case SaveDataType::SystemSaveData: | 114 | case SaveDataType::SystemSaveData: |
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h index d69ef6741..024a305d3 100644 --- a/src/core/file_sys/savedata_factory.h +++ b/src/core/file_sys/savedata_factory.h | |||
| @@ -52,6 +52,9 @@ public: | |||
| 52 | 52 | ||
| 53 | ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta); | 53 | ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta); |
| 54 | 54 | ||
| 55 | VirtualDir GetSaveDataSpaceDirectory(SaveDataSpaceId space); | ||
| 56 | |||
| 57 | static std::string GetSaveDataSpaceIdPath(SaveDataSpaceId space); | ||
| 55 | static std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, | 58 | static std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, |
| 56 | u128 user_id, u64 save_id); | 59 | u128 user_id, u64 save_id); |
| 57 | 60 | ||