diff options
| author | 2020-05-28 22:36:39 -0400 | |
|---|---|---|
| committer | 2020-05-28 22:36:39 -0400 | |
| commit | 5242b2152440af06a88f68ab0a09747b9dea643b (patch) | |
| tree | df3cbbf3dee3ce8ddd30fbf79ada237fbf0e6f45 /src | |
| parent | Merge pull request #3993 from ReinUsesLisp/fix-zla (diff) | |
| parent | Make copying directory string more concise (diff) | |
| download | yuzu-5242b2152440af06a88f68ab0a09747b9dea643b.tar.gz yuzu-5242b2152440af06a88f68ab0a09747b9dea643b.tar.xz yuzu-5242b2152440af06a88f68ab0a09747b9dea643b.zip | |
Merge pull request #4002 from lat9nq/fix-nix-mod-directories
patch_manager: Add support for case-sensitivity on Linux
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 34 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 5 |
2 files changed, 31 insertions, 8 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index b93aa6935..c47ff863e 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/file_util.h" | 10 | #include "common/file_util.h" |
| 11 | #include "common/hex_util.h" | 11 | #include "common/hex_util.h" |
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "common/string_util.h" | ||
| 13 | #include "core/core.h" | 14 | #include "core/core.h" |
| 14 | #include "core/file_sys/content_archive.h" | 15 | #include "core/file_sys/content_archive.h" |
| 15 | #include "core/file_sys/control_metadata.h" | 16 | #include "core/file_sys/control_metadata.h" |
| @@ -48,6 +49,23 @@ std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { | |||
| 48 | return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); | 49 | return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 52 | std::shared_ptr<VfsDirectory> FindSubdirectoryCaseless(const std::shared_ptr<VfsDirectory> dir, | ||
| 53 | std::string_view name) { | ||
| 54 | #ifdef _WIN32 | ||
| 55 | return dir->GetSubdirectory(name); | ||
| 56 | #else | ||
| 57 | const auto subdirs = dir->GetSubdirectories(); | ||
| 58 | for (const auto& subdir : subdirs) { | ||
| 59 | std::string dir_name = Common::ToLower(subdir->GetName()); | ||
| 60 | if (dir_name == name) { | ||
| 61 | return subdir; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | return nullptr; | ||
| 66 | #endif | ||
| 67 | } | ||
| 68 | |||
| 51 | PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} | 69 | PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} |
| 52 | 70 | ||
| 53 | PatchManager::~PatchManager() = default; | 71 | PatchManager::~PatchManager() = default; |
| @@ -104,7 +122,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 104 | if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) | 122 | if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) |
| 105 | continue; | 123 | continue; |
| 106 | 124 | ||
| 107 | auto exefs_dir = subdir->GetSubdirectory("exefs"); | 125 | auto exefs_dir = FindSubdirectoryCaseless(subdir, "exefs"); |
| 108 | if (exefs_dir != nullptr) | 126 | if (exefs_dir != nullptr) |
| 109 | layers.push_back(std::move(exefs_dir)); | 127 | layers.push_back(std::move(exefs_dir)); |
| 110 | } | 128 | } |
| @@ -130,7 +148,7 @@ std::vector<VirtualFile> PatchManager::CollectPatches(const std::vector<VirtualD | |||
| 130 | if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) | 148 | if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) |
| 131 | continue; | 149 | continue; |
| 132 | 150 | ||
| 133 | auto exefs_dir = subdir->GetSubdirectory("exefs"); | 151 | auto exefs_dir = FindSubdirectoryCaseless(subdir, "exefs"); |
| 134 | if (exefs_dir != nullptr) { | 152 | if (exefs_dir != nullptr) { |
| 135 | for (const auto& file : exefs_dir->GetFiles()) { | 153 | for (const auto& file : exefs_dir->GetFiles()) { |
| 136 | if (file->GetExtension() == "ips") { | 154 | if (file->GetExtension() == "ips") { |
| @@ -295,7 +313,7 @@ std::vector<Core::Memory::CheatEntry> PatchManager::CreateCheatList( | |||
| 295 | continue; | 313 | continue; |
| 296 | } | 314 | } |
| 297 | 315 | ||
| 298 | auto cheats_dir = subdir->GetSubdirectory("cheats"); | 316 | auto cheats_dir = FindSubdirectoryCaseless(subdir, "cheats"); |
| 299 | if (cheats_dir != nullptr) { | 317 | if (cheats_dir != nullptr) { |
| 300 | auto res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, true); | 318 | auto res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, true); |
| 301 | if (res.has_value()) { | 319 | if (res.has_value()) { |
| @@ -340,11 +358,11 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t | |||
| 340 | continue; | 358 | continue; |
| 341 | } | 359 | } |
| 342 | 360 | ||
| 343 | auto romfs_dir = subdir->GetSubdirectory("romfs"); | 361 | auto romfs_dir = FindSubdirectoryCaseless(subdir, "romfs"); |
| 344 | if (romfs_dir != nullptr) | 362 | if (romfs_dir != nullptr) |
| 345 | layers.push_back(std::move(romfs_dir)); | 363 | layers.push_back(std::move(romfs_dir)); |
| 346 | 364 | ||
| 347 | auto ext_dir = subdir->GetSubdirectory("romfs_ext"); | 365 | auto ext_dir = FindSubdirectoryCaseless(subdir, "romfs_ext"); |
| 348 | if (ext_dir != nullptr) | 366 | if (ext_dir != nullptr) |
| 349 | layers_ext.push_back(std::move(ext_dir)); | 367 | layers_ext.push_back(std::move(ext_dir)); |
| 350 | } | 368 | } |
| @@ -470,7 +488,7 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 470 | for (const auto& mod : mod_dir->GetSubdirectories()) { | 488 | for (const auto& mod : mod_dir->GetSubdirectories()) { |
| 471 | std::string types; | 489 | std::string types; |
| 472 | 490 | ||
| 473 | const auto exefs_dir = mod->GetSubdirectory("exefs"); | 491 | const auto exefs_dir = FindSubdirectoryCaseless(mod, "exefs"); |
| 474 | if (IsDirValidAndNonEmpty(exefs_dir)) { | 492 | if (IsDirValidAndNonEmpty(exefs_dir)) { |
| 475 | bool ips = false; | 493 | bool ips = false; |
| 476 | bool ipswitch = false; | 494 | bool ipswitch = false; |
| @@ -494,9 +512,9 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 494 | if (layeredfs) | 512 | if (layeredfs) |
| 495 | AppendCommaIfNotEmpty(types, "LayeredExeFS"); | 513 | AppendCommaIfNotEmpty(types, "LayeredExeFS"); |
| 496 | } | 514 | } |
| 497 | if (IsDirValidAndNonEmpty(mod->GetSubdirectory("romfs"))) | 515 | if (IsDirValidAndNonEmpty(FindSubdirectoryCaseless(mod, "romfs"))) |
| 498 | AppendCommaIfNotEmpty(types, "LayeredFS"); | 516 | AppendCommaIfNotEmpty(types, "LayeredFS"); |
| 499 | if (IsDirValidAndNonEmpty(mod->GetSubdirectory("cheats"))) | 517 | if (IsDirValidAndNonEmpty(FindSubdirectoryCaseless(mod, "cheats"))) |
| 500 | AppendCommaIfNotEmpty(types, "Cheats"); | 518 | AppendCommaIfNotEmpty(types, "Cheats"); |
| 501 | 519 | ||
| 502 | if (types.empty()) | 520 | if (types.empty()) |
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index ec6db524d..f4cb918dd 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h | |||
| @@ -29,6 +29,11 @@ enum class TitleVersionFormat : u8 { | |||
| 29 | std::string FormatTitleVersion(u32 version, | 29 | std::string FormatTitleVersion(u32 version, |
| 30 | TitleVersionFormat format = TitleVersionFormat::ThreeElements); | 30 | TitleVersionFormat format = TitleVersionFormat::ThreeElements); |
| 31 | 31 | ||
| 32 | // Returns a directory with name matching name case-insensitive. Returns nullptr if directory | ||
| 33 | // doesn't have a directory with name. | ||
| 34 | std::shared_ptr<VfsDirectory> FindSubdirectoryCaseless(const std::shared_ptr<VfsDirectory> dir, | ||
| 35 | std::string_view name); | ||
| 36 | |||
| 32 | // A centralized class to manage patches to games. | 37 | // A centralized class to manage patches to games. |
| 33 | class PatchManager { | 38 | class PatchManager { |
| 34 | public: | 39 | public: |