diff options
| author | 2018-11-13 18:51:08 -0800 | |
|---|---|---|
| committer | 2018-11-13 18:51:08 -0800 | |
| commit | 9b1262374382a32c4aec5e14d67eed6cd09249bb (patch) | |
| tree | 357554bcbd7eb477a90e0451868e2afd8536ccd7 /src/core/file_sys | |
| parent | Merge pull request #1628 from greggameplayer/Texture2DArray (diff) | |
| parent | ns: Implement command 400: GetApplicationControlData (diff) | |
| download | yuzu-9b1262374382a32c4aec5e14d67eed6cd09249bb.tar.gz yuzu-9b1262374382a32c4aec5e14d67eed6cd09249bb.tar.xz yuzu-9b1262374382a32c4aec5e14d67eed6cd09249bb.zip | |
Merge pull request #1608 from DarkLordZach/save-data-reader
[ns|fsp_srv]: Implement various functions to boot Checkpoint
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/control_metadata.cpp | 6 | ||||
| -rw-r--r-- | src/core/file_sys/control_metadata.h | 1 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 32 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.h | 3 |
4 files changed, 28 insertions, 14 deletions
diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp index a012c2be9..c8fa912bf 100644 --- a/src/core/file_sys/control_metadata.cpp +++ b/src/core/file_sys/control_metadata.cpp | |||
| @@ -66,4 +66,10 @@ std::string NACP::GetVersionString() const { | |||
| 66 | return Common::StringFromFixedZeroTerminatedBuffer(raw->version_string.data(), | 66 | return Common::StringFromFixedZeroTerminatedBuffer(raw->version_string.data(), |
| 67 | raw->version_string.size()); | 67 | raw->version_string.size()); |
| 68 | } | 68 | } |
| 69 | |||
| 70 | std::vector<u8> NACP::GetRawBytes() const { | ||
| 71 | std::vector<u8> out(sizeof(RawNACP)); | ||
| 72 | std::memcpy(out.data(), raw.get(), sizeof(RawNACP)); | ||
| 73 | return out; | ||
| 74 | } | ||
| 69 | } // namespace FileSys | 75 | } // namespace FileSys |
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 141f7e056..bfaad46b4 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h | |||
| @@ -81,6 +81,7 @@ public: | |||
| 81 | u64 GetTitleId() const; | 81 | u64 GetTitleId() const; |
| 82 | u64 GetDLCBaseTitleId() const; | 82 | u64 GetDLCBaseTitleId() const; |
| 83 | std::string GetVersionString() const; | 83 | std::string GetVersionString() const; |
| 84 | std::vector<u8> GetRawBytes() const; | ||
| 84 | 85 | ||
| 85 | private: | 86 | private: |
| 86 | std::unique_ptr<RawNACP> raw; | 87 | std::unique_ptr<RawNACP> raw; |
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index ef1aaebbb..5434f2149 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) const { |
| 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..2a0088040 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) const; | ||
| 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 | ||