patch_manager: Apply layered exefs patches from 'atmosphere' SD directory

This commit is contained in:
tech-ticks 2022-04-07 23:02:44 +02:00
parent 37199c5f90
commit f05e87402a

View file

@ -148,29 +148,33 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const {
// LayeredExeFS // LayeredExeFS
const auto load_dir = fs_controller.GetModificationLoadRoot(title_id); const auto load_dir = fs_controller.GetModificationLoadRoot(title_id);
const auto sdmc_load_dir = fs_controller.GetSDMCModificationLoadRoot(title_id);
std::vector<VirtualDir> patch_dirs = {sdmc_load_dir};
if (load_dir != nullptr && load_dir->GetSize() > 0) { if (load_dir != nullptr && load_dir->GetSize() > 0) {
auto patch_dirs = load_dir->GetSubdirectories(); const auto load_patch_dirs = load_dir->GetSubdirectories();
std::sort( patch_dirs.insert(patch_dirs.end(), load_patch_dirs.begin(), load_patch_dirs.end());
patch_dirs.begin(), patch_dirs.end(), }
[](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); });
std::vector<VirtualDir> layers; std::sort(patch_dirs.begin(), patch_dirs.end(),
layers.reserve(patch_dirs.size() + 1); [](const VirtualDir& l, const VirtualDir& r) { return l->GetName() < r->GetName(); });
for (const auto& subdir : patch_dirs) {
if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end())
continue;
auto exefs_dir = FindSubdirectoryCaseless(subdir, "exefs"); std::vector<VirtualDir> layers;
if (exefs_dir != nullptr) layers.reserve(patch_dirs.size() + 1);
layers.push_back(std::move(exefs_dir)); for (const auto& subdir : patch_dirs) {
} if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end())
layers.push_back(exefs); continue;
auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers)); auto exefs_dir = FindSubdirectoryCaseless(subdir, "exefs");
if (layered != nullptr) { if (exefs_dir != nullptr)
LOG_INFO(Loader, " ExeFS: LayeredExeFS patches applied successfully"); layers.push_back(std::move(exefs_dir));
exefs = std::move(layered); }
} layers.push_back(exefs);
auto layered = LayeredVfsDirectory::MakeLayeredDirectory(std::move(layers));
if (layered != nullptr) {
LOG_INFO(Loader, " ExeFS: LayeredExeFS patches applied successfully");
exefs = std::move(layered);
} }
if (Settings::values.dump_exefs) { if (Settings::values.dump_exefs) {
@ -536,11 +540,20 @@ PatchManager::PatchVersionNames PatchManager::GetPatchVersionNames(VirtualFile u
// SDMC mod directory (RomFS LayeredFS) // SDMC mod directory (RomFS LayeredFS)
const auto sdmc_mod_dir = fs_controller.GetSDMCModificationLoadRoot(title_id); const auto sdmc_mod_dir = fs_controller.GetSDMCModificationLoadRoot(title_id);
if (sdmc_mod_dir != nullptr && sdmc_mod_dir->GetSize() > 0 && if (sdmc_mod_dir != nullptr && sdmc_mod_dir->GetSize() > 0) {
IsDirValidAndNonEmpty(FindSubdirectoryCaseless(sdmc_mod_dir, "romfs"))) { std::string types;
const auto mod_disabled = if (IsDirValidAndNonEmpty(FindSubdirectoryCaseless(sdmc_mod_dir, "exefs"))) {
std::find(disabled.begin(), disabled.end(), "SDMC") != disabled.end(); AppendCommaIfNotEmpty(types, "LayeredExeFS");
out.insert_or_assign(mod_disabled ? "[D] SDMC" : "SDMC", "LayeredFS"); }
if (IsDirValidAndNonEmpty(FindSubdirectoryCaseless(sdmc_mod_dir, "romfs"))) {
AppendCommaIfNotEmpty(types, "LayeredFS");
}
if (!types.empty()) {
const auto mod_disabled =
std::find(disabled.begin(), disabled.end(), "SDMC") != disabled.end();
out.insert_or_assign(mod_disabled ? "[D] SDMC" : "SDMC", types);
}
} }
// DLC // DLC