diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cpp index 6d9007731..19e1eb981 100644 --- a/src/core/file_sys/archive_ncch.cpp +++ b/src/core/file_sys/archive_ncch.cpp @@ -13,7 +13,9 @@ #include "core/file_sys/archive_ncch.h" #include "core/file_sys/errors.h" #include "core/file_sys/ivfc_archive.h" +#include "core/file_sys/ncch_container.h" #include "core/hle/service/fs/archive.h" +#include "core/loader/loader.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // FileSys namespace @@ -25,8 +27,8 @@ static std::string GetNCCHContainerPath(const std::string& nand_directory) { } static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) { - return Common::StringFromFormat("%s%08x/%08x/content/00000000.app.romfs", mount_point.c_str(), - high, low); + return Common::StringFromFormat("%s%08x/%08x/content/00000000.app", mount_point.c_str(), high, + low); } ArchiveFactory_NCCH::ArchiveFactory_NCCH(const std::string& nand_directory) @@ -38,9 +40,14 @@ ResultVal> ArchiveFactory_NCCH::Open(const Path& u32 high = data[1]; u32 low = data[0]; std::string file_path = GetNCCHPath(mount_point, high, low); - auto file = std::make_shared(file_path, "rb"); - if (!file->IsOpen()) { + std::shared_ptr romfs_file; + u64 romfs_offset = 0; + u64 romfs_size = 0; + auto ncch_container = NCCHContainer(file_path); + + if (ncch_container.ReadRomFS(romfs_file, romfs_offset, romfs_size) != + Loader::ResultStatus::Success) { // High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list). constexpr u32 shared_data_archive = 0x0004009B; constexpr u32 system_data_archive = 0x000400DB; @@ -74,9 +81,8 @@ ResultVal> ArchiveFactory_NCCH::Open(const Path& } return ERROR_NOT_FOUND; } - auto size = file->GetSize(); - auto archive = std::make_unique(file, 0, size); + auto archive = std::make_unique(romfs_file, romfs_offset, romfs_size); return MakeResult>(std::move(archive)); }