diff options
author | bunnei <bunneidev@gmail.com> | 2018-08-21 02:17:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 02:17:57 +0200 |
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 yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.gz yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.bz2 yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.lz yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.xz yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.tar.zst yuzu-dd70ddad7edb7cfbdddaed0ac657544a613d46e2.zip |
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 { Control = 2, Manual = 3, Data = 4, + Data_Unknown5 = 5, ///< Seems to be used on some system archives }; 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) { case NCAContentType::Control: return ContentRecordType::Control; case NCAContentType::Data: + case NCAContentType::Data_Unknown5: return ContentRecordType::Data; case NCAContentType::Manual: // TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal. return ContentRecordType::Manual; default: - UNREACHABLE(); + UNREACHABLE_MSG("Invalid NCAContentType={:02X}", static_cast<u8>(type)); } } 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 @@ #include <memory> #include "common/common_types.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/file_sys/romfs_factory.h" +#include "core/hle/kernel/process.h" namespace FileSys { @@ -17,9 +19,41 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) { } } -ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id) { - // TODO(DarkLordZach): Use title id. +ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() { return MakeResult<VirtualFile>(file); } +ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) { + switch (storage) { + case StorageId::NandSystem: { + const auto res = Service::FileSystem::GetSystemNANDContents()->GetEntry(title_id, type); + if (res == nullptr) { + // TODO(DarkLordZach): Find the right error code to use here + return ResultCode(-1); + } + const auto romfs = res->GetRomFS(); + if (romfs == nullptr) { + // TODO(DarkLordZach): Find the right error code to use here + return ResultCode(-1); + } + return MakeResult<VirtualFile>(romfs); + } + case StorageId::NandUser: { + const auto res = Service::FileSystem::GetUserNANDContents()->GetEntry(title_id, type); + if (res == nullptr) { + // TODO(DarkLordZach): Find the right error code to use here + return ResultCode(-1); + } + const auto romfs = res->GetRomFS(); + if (romfs == nullptr) { + // TODO(DarkLordZach): Find the right error code to use here + return ResultCode(-1); + } + return MakeResult<VirtualFile>(romfs); + } + default: + UNIMPLEMENTED_MSG("Unimplemented storage_id={:02X}", static_cast<u8>(storage)); + } +} + } // 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 @@ namespace FileSys { +enum class StorageId : u8 { + None = 0, + Host = 1, + GameCard = 2, + NandSystem = 3, + NandUser = 4, + SdCard = 5, +}; + /// File system interface to the RomFS archive class RomFSFactory { public: explicit RomFSFactory(Loader::AppLoader& app_loader); - ResultVal<VirtualFile> Open(u64 title_id); + ResultVal<VirtualFile> OpenCurrentProcess(); + ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type); private: VirtualFile file; |