diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 561ad67a7..4b3b5e665 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -70,37 +70,40 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 70 | 70 | ||
| 71 | static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType type) { | 71 | static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType type) { |
| 72 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | 72 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); |
| 73 | if (type == ContentRecordType::Program && load_dir != nullptr && load_dir->GetSize() > 0) { | 73 | if (type != ContentRecordType::Program || load_dir == nullptr || load_dir->GetSize() <= 0) { |
| 74 | auto extracted = ExtractRomFS(romfs); | 74 | return; |
| 75 | 75 | } | |
| 76 | if (extracted != nullptr) { | ||
| 77 | auto patch_dirs = load_dir->GetSubdirectories(); | ||
| 78 | std::sort(patch_dirs.begin(), patch_dirs.end(), | ||
| 79 | [](const VirtualDir& l, const VirtualDir& r) { | ||
| 80 | return l->GetName() < r->GetName(); | ||
| 81 | }); | ||
| 82 | |||
| 83 | std::vector<VirtualDir> layers; | ||
| 84 | layers.reserve(patch_dirs.size() + 1); | ||
| 85 | for (const auto& subdir : patch_dirs) { | ||
| 86 | auto romfs_dir = subdir->GetSubdirectory("romfs"); | ||
| 87 | if (romfs_dir != nullptr) | ||
| 88 | layers.push_back(std::move(romfs_dir)); | ||
| 89 | } | ||
| 90 | 76 | ||
| 91 | layers.push_back(std::move(extracted)); | 77 | auto extracted = ExtractRomFS(romfs); |
| 78 | if (extracted == nullptr) { | ||
| 79 | return; | ||
| 80 | } | ||
| 92 | 81 | ||
| 93 | auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers)); | 82 | auto patch_dirs = load_dir->GetSubdirectories(); |
| 94 | if (layered != nullptr) { | 83 | std::sort(patch_dirs.begin(), patch_dirs.end(), |
| 95 | auto packed = CreateRomFS(std::move(layered)); | 84 | [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); }); |
| 96 | 85 | ||
| 97 | if (packed != nullptr) { | 86 | std::vector<VirtualDir> layers; |
| 98 | LOG_INFO(Loader, " RomFS: LayeredFS patches applied successfully"); | 87 | layers.reserve(patch_dirs.size() + 1); |
| 99 | romfs = std::move(packed); | 88 | for (const auto& subdir : patch_dirs) { |
| 100 | } | 89 | auto romfs_dir = subdir->GetSubdirectory("romfs"); |
| 101 | } | 90 | if (romfs_dir != nullptr) |
| 102 | } | 91 | layers.push_back(std::move(romfs_dir)); |
| 103 | } | 92 | } |
| 93 | layers.push_back(std::move(extracted)); | ||
| 94 | |||
| 95 | auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers)); | ||
| 96 | if (layered == nullptr) { | ||
| 97 | return; | ||
| 98 | } | ||
| 99 | |||
| 100 | auto packed = CreateRomFS(std::move(layered)); | ||
| 101 | if (packed == nullptr) { | ||
| 102 | return; | ||
| 103 | } | ||
| 104 | |||
| 105 | LOG_INFO(Loader, " RomFS: LayeredFS patches applied successfully"); | ||
| 106 | romfs = std::move(packed); | ||
| 104 | } | 107 | } |
| 105 | 108 | ||
| 106 | VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, | 109 | VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, |