diff options
| author | Max Thomas <mtinc2@gmail.com> | 2017-09-25 00:17:38 -0600 |
|---|---|---|
| committer | B3n30 <bene_thomas@web.de> | 2017-09-25 08:17:38 +0200 |
| commit | c91ccbd0ba4118554d7377bbc3bd4c64f9bccf84 (patch) | |
| tree | d56b08a52a11f229e9ce30aeda2b22bfccd48034 /src/core/file_sys/archive_selfncch.cpp | |
| parent | d673d508dd1ca463dc72ff68b5582ee56d62f142 (diff) | |
Loader/NCCH: Add support for loading application updates (#2927)
* loader/ncch: split NCCH parsing into its own file
* loader/ncch: add support for loading update NCCHs from the SD card
* loader/ncch: fix formatting
* file_sys/ncch_container: Return a value for OpenFile
* loader/ncch: cleanup, always instantiate overlay_ncch to base_ncch
* file_sys/ncch_container: better encryption checks, allow non-app NCCHs to load properly and for the existence of NCCH structures to be checked
* file_sys/ncch_container: pass filepath as a const reference
Diffstat (limited to 'src/core/file_sys/archive_selfncch.cpp')
| -rw-r--r-- | src/core/file_sys/archive_selfncch.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/core/file_sys/archive_selfncch.cpp b/src/core/file_sys/archive_selfncch.cpp index 298a37a44..7dc91a405 100644 --- a/src/core/file_sys/archive_selfncch.cpp +++ b/src/core/file_sys/archive_selfncch.cpp @@ -102,8 +102,7 @@ public: switch (static_cast<SelfNCCHFilePathType>(file_path.type)) { case SelfNCCHFilePathType::UpdateRomFS: - LOG_WARNING(Service_FS, "(STUBBED) open update RomFS"); - return OpenRomFS(); + return OpenUpdateRomFS(); case SelfNCCHFilePathType::RomFS: return OpenRomFS(); @@ -179,6 +178,17 @@ private: } } + ResultVal<std::unique_ptr<FileBackend>> OpenUpdateRomFS() const { + if (ncch_data.update_romfs_file) { + return MakeResult<std::unique_ptr<FileBackend>>(std::make_unique<IVFCFile>( + ncch_data.update_romfs_file, ncch_data.update_romfs_offset, + ncch_data.update_romfs_size)); + } else { + LOG_INFO(Service_FS, "Unable to read update RomFS"); + return ERROR_ROMFS_NOT_FOUND; + } + } + ResultVal<std::unique_ptr<FileBackend>> OpenExeFS(const std::string& filename) const { if (filename == "icon") { if (ncch_data.icon) { @@ -218,11 +228,19 @@ private: }; ArchiveFactory_SelfNCCH::ArchiveFactory_SelfNCCH(Loader::AppLoader& app_loader) { - std::shared_ptr<FileUtil::IOFile> romfs_file_; + std::shared_ptr<FileUtil::IOFile> romfs_file; + if (Loader::ResultStatus::Success == + app_loader.ReadRomFS(romfs_file, ncch_data.romfs_offset, ncch_data.romfs_size)) { + + ncch_data.romfs_file = std::move(romfs_file); + } + + std::shared_ptr<FileUtil::IOFile> update_romfs_file; if (Loader::ResultStatus::Success == - app_loader.ReadRomFS(romfs_file_, ncch_data.romfs_offset, ncch_data.romfs_size)) { + app_loader.ReadUpdateRomFS(update_romfs_file, ncch_data.update_romfs_offset, + ncch_data.update_romfs_size)) { - ncch_data.romfs_file = std::move(romfs_file_); + ncch_data.update_romfs_file = std::move(update_romfs_file); } std::vector<u8> buffer; |
