summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/patch_manager.cpp
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-09-24 03:50:16 +0200
committerZach Hilman <zachhilman@gmail.com>2018-09-24 03:50:20 +0200
commitb3c2ec362bbbdd89da9c0aa84b425717f5e3d351 (patch)
treed3f4e621532f1f280f94bac4e6d071707aabbd35 /src/core/file_sys/patch_manager.cpp
parentqt: Add UI elements for LayeredFS and related tools (diff)
downloadyuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar
yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.gz
yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.bz2
yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.lz
yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.xz
yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.tar.zst
yuzu-b3c2ec362bbbdd89da9c0aa84b425717f5e3d351.zip
Diffstat (limited to '')
-rw-r--r--src/core/file_sys/patch_manager.cpp66
1 files changed, 35 insertions, 31 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index 74a0acf1a..af3f9a78f 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -68,33 +68,10 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
return exefs;
}
-VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset,
- ContentRecordType type) const {
- LOG_INFO(Loader, "Patching RomFS for title_id={:016X}, type={:02X}", title_id,
- static_cast<u8>(type));
-
- if (romfs == nullptr)
- return romfs;
-
- const auto installed = Service::FileSystem::GetUnionContents();
-
- // Game Updates
- const auto update_tid = GetUpdateTitleID(title_id);
- const auto update = installed->GetEntryRaw(update_tid, type);
- if (update != nullptr) {
- const auto new_nca = std::make_shared<NCA>(update, romfs, ivfc_offset);
- if (new_nca->GetStatus() == Loader::ResultStatus::Success &&
- new_nca->GetRomFS() != nullptr) {
- LOG_INFO(Loader, " RomFS: Update ({}) applied successfully",
- FormatTitleVersion(installed->GetEntryVersion(update_tid).get_value_or(0)));
- romfs = new_nca->GetRomFS();
- }
- }
-
- // LayeredFS
+static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType type) {
const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id);
if (type == ContentRecordType::Program && load_dir != nullptr && load_dir->GetSize() > 0) {
- const auto extracted = ExtractRomFS(romfs);
+ auto extracted = ExtractRomFS(romfs);
if (extracted != nullptr) {
auto patch_dirs = load_dir->GetSubdirectories();
@@ -106,25 +83,52 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset,
std::vector<VirtualDir> layers;
layers.reserve(patch_dirs.size() + 1);
for (const auto& subdir : patch_dirs) {
- const auto romfs_dir = subdir->GetSubdirectory("romfs");
+ auto romfs_dir = subdir->GetSubdirectory("romfs");
if (romfs_dir != nullptr)
- layers.push_back(romfs_dir);
+ layers.push_back(std::move(romfs_dir));
}
- layers.push_back(extracted);
+ layers.push_back(std::move(extracted));
const auto layered = LayerDirectories(layers);
if (layered != nullptr) {
- const auto packed = CreateRomFS(layered);
+ auto packed = CreateRomFS(layered);
if (packed != nullptr) {
LOG_INFO(Loader, " RomFS: LayeredFS patches applied successfully");
- romfs = packed;
+ romfs = std::move(packed);
}
}
}
}
+}
+
+VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset,
+ ContentRecordType type) const {
+ LOG_INFO(Loader, "Patching RomFS for title_id={:016X}, type={:02X}", title_id,
+ static_cast<u8>(type));
+
+ if (romfs == nullptr)
+ return romfs;
+
+ const auto installed = Service::FileSystem::GetUnionContents();
+
+ // Game Updates
+ const auto update_tid = GetUpdateTitleID(title_id);
+ const auto update = installed->GetEntryRaw(update_tid, type);
+ if (update != nullptr) {
+ const auto new_nca = std::make_shared<NCA>(update, romfs, ivfc_offset);
+ if (new_nca->GetStatus() == Loader::ResultStatus::Success &&
+ new_nca->GetRomFS() != nullptr) {
+ LOG_INFO(Loader, " RomFS: Update ({}) applied successfully",
+ FormatTitleVersion(installed->GetEntryVersion(update_tid).get_value_or(0)));
+ romfs = new_nca->GetRomFS();
+ }
+ }
+
+ // LayeredFS
+ ApplyLayeredFS(romfs, title_id, type);
return romfs;
}
@@ -153,7 +157,7 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const {
const auto lfs_dir = Service::FileSystem::GetModificationLoadRoot(title_id);
if (lfs_dir != nullptr && lfs_dir->GetSize() > 0)
- out[PatchType::LayeredFS] = "";
+ out.insert_or_assign(PatchType::LayeredFS, "");
return out;
}