summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 @@
13#include "core/file_sys/archive_ncch.h" 13#include "core/file_sys/archive_ncch.h"
14#include "core/file_sys/errors.h" 14#include "core/file_sys/errors.h"
15#include "core/file_sys/ivfc_archive.h" 15#include "core/file_sys/ivfc_archive.h"
16#include "core/file_sys/ncch_container.h"
16#include "core/hle/service/fs/archive.h" 17#include "core/hle/service/fs/archive.h"
18#include "core/loader/loader.h"
17 19
18//////////////////////////////////////////////////////////////////////////////////////////////////// 20////////////////////////////////////////////////////////////////////////////////////////////////////
19// FileSys namespace 21// FileSys namespace
@@ -25,8 +27,8 @@ static std::string GetNCCHContainerPath(const std::string& nand_directory) {
25} 27}
26 28
27static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) { 29static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) {
28 return Common::StringFromFormat("%s%08x/%08x/content/00000000.app.romfs", mount_point.c_str(), 30 return Common::StringFromFormat("%s%08x/%08x/content/00000000.app", mount_point.c_str(), high,
29 high, low); 31 low);
30} 32}
31 33
32ArchiveFactory_NCCH::ArchiveFactory_NCCH(const std::string& nand_directory) 34ArchiveFactory_NCCH::ArchiveFactory_NCCH(const std::string& nand_directory)
@@ -38,9 +40,14 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
38 u32 high = data[1]; 40 u32 high = data[1];
39 u32 low = data[0]; 41 u32 low = data[0];
40 std::string file_path = GetNCCHPath(mount_point, high, low); 42 std::string file_path = GetNCCHPath(mount_point, high, low);
41 auto file = std::make_shared<FileUtil::IOFile>(file_path, "rb");
42 43
43 if (!file->IsOpen()) { 44 std::shared_ptr<FileUtil::IOFile> romfs_file;
45 u64 romfs_offset = 0;
46 u64 romfs_size = 0;
47 auto ncch_container = NCCHContainer(file_path);
48
49 if (ncch_container.ReadRomFS(romfs_file, romfs_offset, romfs_size) !=
50 Loader::ResultStatus::Success) {
44 // High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list). 51 // High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list).
45 constexpr u32 shared_data_archive = 0x0004009B; 52 constexpr u32 shared_data_archive = 0x0004009B;
46 constexpr u32 system_data_archive = 0x000400DB; 53 constexpr u32 system_data_archive = 0x000400DB;
@@ -74,9 +81,8 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
74 } 81 }
75 return ERROR_NOT_FOUND; 82 return ERROR_NOT_FOUND;
76 } 83 }
77 auto size = file->GetSize();
78 84
79 auto archive = std::make_unique<IVFCArchive>(file, 0, size); 85 auto archive = std::make_unique<IVFCArchive>(romfs_file, romfs_offset, romfs_size);
80 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); 86 return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
81} 87}
82 88