fsmitm_romfsbuild: Add support for stubbing and IPS patches in LFS

This commit is contained in:
Zach Hilman 2018-10-01 09:12:14 -04:00
parent f85f2b3728
commit bc4bec8a60
1 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include "common/alignment.h"
#include "common/assert.h"
#include "core/file_sys/fsmitm_romfsbuild.h"
#include "core/file_sys/ips_layer.h"
#include "core/file_sys/vfs.h"
#include "core/file_sys/vfs_vector.h"
@ -138,6 +139,9 @@ 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;
@ -151,6 +155,9 @@ 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;
@ -162,6 +169,13 @@ void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs,
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);
}
child->size = child->source->GetSize();
AddFile(parent, child);