diff options
| author | 2018-08-20 20:17:57 -0400 | |
|---|---|---|
| committer | 2018-08-20 20:17:57 -0400 | |
| commit | dd70ddad7edb7cfbdddaed0ac657544a613d46e2 (patch) | |
| tree | 76145c48a1f92f64ef53ef8527df392b0fac10a6 /src/core/file_sys | |
| parent | Merge pull request #1127 from yuzu-emu/revert-838-port-3616 (diff) | |
| parent | registration: Add Data_Unknown5 NCAContentType (diff) | |
| download | yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.gz yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.xz yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.zip | |
Merge pull request #1095 from DarkLordZach/sysarchives
filesystem: Add support for loading of system archives
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/content_archive.h | 1 | ||||
| -rw-r--r-- | src/core/file_sys/registered_cache.cpp | 3 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 38 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.h | 12 |
4 files changed, 50 insertions, 4 deletions
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index b82e65ad5..4b74c54ec 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h | |||
| @@ -27,6 +27,7 @@ enum class NCAContentType : u8 { | |||
| 27 | Control = 2, | 27 | Control = 2, |
| 28 | Manual = 3, | 28 | Manual = 3, |
| 29 | Data = 4, | 29 | Data = 4, |
| 30 | Data_Unknown5 = 5, ///< Seems to be used on some system archives | ||
| 30 | }; | 31 | }; |
| 31 | 32 | ||
| 32 | enum class NCASectionCryptoType : u8 { | 33 | enum class NCASectionCryptoType : u8 { |
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index d25eeee34..e90dc6695 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -77,12 +77,13 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) { | |||
| 77 | case NCAContentType::Control: | 77 | case NCAContentType::Control: |
| 78 | return ContentRecordType::Control; | 78 | return ContentRecordType::Control; |
| 79 | case NCAContentType::Data: | 79 | case NCAContentType::Data: |
| 80 | case NCAContentType::Data_Unknown5: | ||
| 80 | return ContentRecordType::Data; | 81 | return ContentRecordType::Data; |
| 81 | case NCAContentType::Manual: | 82 | case NCAContentType::Manual: |
| 82 | // TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal. | 83 | // TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal. |
| 83 | return ContentRecordType::Manual; | 84 | return ContentRecordType::Manual; |
| 84 | default: | 85 | default: |
| 85 | UNREACHABLE(); | 86 | UNREACHABLE_MSG("Invalid NCAContentType={:02X}", static_cast<u8>(type)); |
| 86 | } | 87 | } |
| 87 | } | 88 | } |
| 88 | 89 | ||
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 54fbd3267..1b3824a61 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -6,7 +6,9 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | ||
| 9 | #include "core/file_sys/romfs_factory.h" | 10 | #include "core/file_sys/romfs_factory.h" |
| 11 | #include "core/hle/kernel/process.h" | ||
| 10 | 12 | ||
| 11 | namespace FileSys { | 13 | namespace FileSys { |
| 12 | 14 | ||
| @@ -17,9 +19,41 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) { | |||
| 17 | } | 19 | } |
| 18 | } | 20 | } |
| 19 | 21 | ||
| 20 | ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id) { | 22 | ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() { |
| 21 | // TODO(DarkLordZach): Use title id. | ||
| 22 | return MakeResult<VirtualFile>(file); | 23 | return MakeResult<VirtualFile>(file); |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 26 | ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) { | ||
| 27 | switch (storage) { | ||
| 28 | case StorageId::NandSystem: { | ||
| 29 | const auto res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type); | ||
| 30 | if (res == nullptr) { | ||
| 31 | // TODO(DarkLordZach): Find the right error code to use here | ||
| 32 | return ResultCode(-1); | ||
| 33 | } | ||
| 34 | const auto romfs = res->GetRomFS(); | ||
| 35 | if (romfs == nullptr) { | ||
| 36 | // TODO(DarkLordZach): Find the right error code to use here | ||
| 37 | return ResultCode(-1); | ||
| 38 | } | ||
| 39 | return MakeResult<VirtualFile>(romfs); | ||
| 40 | } | ||
| 41 | case StorageId::NandUser: { | ||
| 42 | const auto res = Service::FileSystem::GetUserNANDContents()->GetEntry(title_id, type); | ||
| 43 | if (res == nullptr) { | ||
| 44 | // TODO(DarkLordZach): Find the right error code to use here | ||
| 45 | return ResultCode(-1); | ||
| 46 | } | ||
| 47 | const auto romfs = res->GetRomFS(); | ||
| 48 | if (romfs == nullptr) { | ||
| 49 | // TODO(DarkLordZach): Find the right error code to use here | ||
| 50 | return ResultCode(-1); | ||
| 51 | } | ||
| 52 | return MakeResult<VirtualFile>(romfs); | ||
| 53 | } | ||
| 54 | default: | ||
| 55 | UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast<u8>(storage)); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 25 | } // namespace FileSys | 59 | } // namespace FileSys |
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h index c19787cd4..455cd4159 100644 --- a/src/core/file_sys/romfs_factory.h +++ b/src/core/file_sys/romfs_factory.h | |||
| @@ -11,12 +11,22 @@ | |||
| 11 | 11 | ||
| 12 | namespace FileSys { | 12 | namespace FileSys { |
| 13 | 13 | ||
| 14 | enum class StorageId : u8 { | ||
| 15 | None = 0, | ||
| 16 | Host = 1, | ||
| 17 | GameCard = 2, | ||
| 18 | NandSystem = 3, | ||
| 19 | NandUser = 4, | ||
| 20 | SdCard = 5, | ||
| 21 | }; | ||
| 22 | |||
| 14 | /// File system interface to the RomFS archive | 23 | /// File system interface to the RomFS archive |
| 15 | class RomFSFactory { | 24 | class RomFSFactory { |
| 16 | public: | 25 | public: |
| 17 | explicit RomFSFactory(Loader::AppLoader& app_loader); | 26 | explicit RomFSFactory(Loader::AppLoader& app_loader); |
| 18 | 27 | ||
| 19 | ResultVal<VirtualFile> Open(u64 title_id); | 28 | ResultVal<VirtualFile> OpenCurrentProcess(); |
| 29 | ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type); | ||
| 20 | 30 | ||
| 21 | private: | 31 | private: |
| 22 | VirtualFile file; | 32 | VirtualFile file; |