diff options
author | Zach Hilman <zachhilman@gmail.com> | 2018-10-02 14:56:56 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2018-10-04 18:29:20 +0200 |
commit | c1e069c066a609103c6b880585738ecabe48ddd2 (patch) | |
tree | bf599fa1e774ae098866d50ca5acbaf3441eb16e /src/core/file_sys/fsmitm_romfsbuild.cpp | |
parent | fsmitm_romfsbuild: Add support for stubbing and IPS patches in LFS (diff) | |
download | yuzu-c1e069c066a609103c6b880585738ecabe48ddd2.tar yuzu-c1e069c066a609103c6b880585738ecabe48ddd2.tar.gz yuzu-c1e069c066a609103c6b880585738ecabe48ddd2.tar.bz2 yuzu-c1e069c066a609103c6b880585738ecabe48ddd2.tar.lz yuzu-c1e069c066a609103c6b880585738ecabe48ddd2.tar.xz yuzu-c1e069c066a609103c6b880585738ecabe48ddd2.tar.zst yuzu-c1e069c066a609103c6b880585738ecabe48ddd2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/file_sys/fsmitm_romfsbuild.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/core/file_sys/fsmitm_romfsbuild.cpp b/src/core/file_sys/fsmitm_romfsbuild.cpp index 4aa8ae369..47b7526c7 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.cpp +++ b/src/core/file_sys/fsmitm_romfsbuild.cpp @@ -124,7 +124,7 @@ static u64 romfs_get_hash_table_count(u64 num_entries) { return count; } -void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs, +void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs, VirtualDir ext, std::shared_ptr<RomFSBuildDirectoryContext> parent) { std::vector<std::shared_ptr<RomFSBuildDirectoryContext>> child_dirs; @@ -139,15 +139,15 @@ void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs, for (const auto& kv : entries) { if (kv.second == VfsEntryType::Directory) { - if (dir->GetSubdirectory(kv.first + ".stub") != nullptr) - continue; - const auto child = std::make_shared<RomFSBuildDirectoryContext>(); // Set child's path. child->cur_path_ofs = parent->path_len + 1; child->path_len = child->cur_path_ofs + static_cast<u32>(kv.first.size()); child->path = parent->path + "/" + kv.first; + if (ext != nullptr && ext->GetFileRelative(child->path + ".stub") != nullptr) + continue; + // Sanity check on path_len ASSERT(child->path_len < FS_MAX_PATH); @@ -155,25 +155,28 @@ void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs, child_dirs.push_back(child); } } else { - if (dir->GetFile(kv.first + ".stub") != nullptr) - continue; - const auto child = std::make_shared<RomFSBuildFileContext>(); // Set child's path. child->cur_path_ofs = parent->path_len + 1; child->path_len = child->cur_path_ofs + static_cast<u32>(kv.first.size()); child->path = parent->path + "/" + kv.first; + if (ext != nullptr && ext->GetFileRelative(child->path + ".stub") != nullptr) + continue; + // Sanity check on path_len ASSERT(child->path_len < FS_MAX_PATH); child->source = root_romfs->GetFileRelative(child->path); - if (dir->GetFile(kv.first + ".ips") != nullptr) { - const auto ips = dir->GetFile(kv.first + ".ips"); - auto patched = PatchIPS(child->source, ips); - if (patched != nullptr) - child->source = std::move(patched); + if (ext != nullptr) { + const auto ips = ext->GetFileRelative(child->path + ".ips"); + + if (ips != nullptr) { + auto patched = PatchIPS(child->source, ips); + if (patched != nullptr) + child->source = std::move(patched); + } } child->size = child->source->GetSize(); @@ -183,7 +186,7 @@ void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs, } for (auto& child : child_dirs) { - this->VisitDirectory(root_romfs, child); + this->VisitDirectory(root_romfs, ext, child); } } @@ -222,14 +225,15 @@ bool RomFSBuildContext::AddFile(std::shared_ptr<RomFSBuildDirectoryContext> pare return true; } -RomFSBuildContext::RomFSBuildContext(VirtualDir base_) : base(std::move(base_)) { +RomFSBuildContext::RomFSBuildContext(VirtualDir base_, VirtualDir ext_) + : base(std::move(base_)), ext(std::move(ext_)) { root = std::make_shared<RomFSBuildDirectoryContext>(); root->path = "\0"; directories.emplace(root->path, root); num_dirs = 1; dir_table_size = 0x18; - VisitDirectory(base, root); + VisitDirectory(base, ext, root); } RomFSBuildContext::~RomFSBuildContext() = default; |