summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshinyquagsire23 <mtinc2@gmail.com>2017-09-26 06:21:39 +0200
committershinyquagsire23 <mtinc2@gmail.com>2017-10-01 18:53:04 +0200
commitc93e5ecfe68028c75e36a861fff2e287875f5794 (patch)
treef7ea3e8c3370d66b74e24e3f31b0204db7c11e42
parentMerge pull request #2973 from huwpascoe/down_count (diff)
downloadyuzu-c93e5ecfe68028c75e36a861fff2e287875f5794.tar
yuzu-c93e5ecfe68028c75e36a861fff2e287875f5794.tar.gz
yuzu-c93e5ecfe68028c75e36a861fff2e287875f5794.tar.bz2
yuzu-c93e5ecfe68028c75e36a861fff2e287875f5794.tar.lz
yuzu-c93e5ecfe68028c75e36a861fff2e287875f5794.tar.xz
yuzu-c93e5ecfe68028c75e36a861fff2e287875f5794.tar.zst
yuzu-c93e5ecfe68028c75e36a861fff2e287875f5794.zip
-rw-r--r--src/core/file_sys/archive_ncch.cpp18
1 files changed, 12 insertions, 6 deletions
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<std::unique_ptr<ArchiveBackend>> 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<FileUtil::IOFile>(file_path, "rb");
- if (!file->IsOpen()) {
+ std::shared_ptr<FileUtil::IOFile> 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<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
}
return ERROR_NOT_FOUND;
}
- auto size = file->GetSize();
- auto archive = std::make_unique<IVFCArchive>(file, 0, size);
+ auto archive = std::make_unique<IVFCArchive>(romfs_file, romfs_offset, romfs_size);
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
}