diff options
| author | 2020-05-27 23:12:56 -0400 | |
|---|---|---|
| committer | 2020-05-27 23:12:56 -0400 | |
| commit | 136c563f76f68f83fc30984097b459f80becdef4 (patch) | |
| tree | 041c76fb42f36aa46d4d5a18398fcf6fc7e2d089 /src | |
| parent | Merge pull request #3946 from ogniK5377/sysverdat-10-0-2 (diff) | |
| download | yuzu-136c563f76f68f83fc30984097b459f80becdef4.tar.gz yuzu-136c563f76f68f83fc30984097b459f80becdef4.tar.xz yuzu-136c563f76f68f83fc30984097b459f80becdef4.zip | |
*nix systems can read any-case patch directories
Changes many patch_manager functions to use a case-less variant of
GetSubdirectory. Fixes patches not showing up on *nix systems when
patch directories are named with odd cases, i.e. `exeFS'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 35 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.h | 5 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index b93aa6935..3d1965abb 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <cstddef> | 7 | #include <cstddef> |
| 8 | #include <cstring> | 8 | #include <cstring> |
| 9 | #include <boost/algorithm/string/case_conv.hpp> | ||
| 9 | 10 | ||
| 10 | #include "common/file_util.h" | 11 | #include "common/file_util.h" |
| 11 | #include "common/hex_util.h" | 12 | #include "common/hex_util.h" |
| @@ -48,6 +49,24 @@ 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 | const std::string& 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 = subdir->GetName(); | ||
| 60 | boost::algorithm::to_lower(dir_name); | ||
| 61 | if (dir_name == name) { | ||
| 62 | return subdir; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | return nullptr; | ||
| 67 | #endif | ||
| 68 | } | ||
| 69 | |||
| 51 | PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} | 70 | PatchManager::PatchManager(u64 title_id) : title_id(title_id) {} |
| 52 | 71 | ||
| 53 | PatchManager::~PatchManager() = default; | 72 | PatchManager::~PatchManager() = default; |
| @@ -104,7 +123,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { | |||
| 104 | if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) | 123 | if (std::find(disabled.begin(), disabled.end(), subdir->GetName()) != disabled.end()) |
| 105 | continue; | 124 | continue; |
| 106 | 125 | ||
| 107 | auto exefs_dir = subdir->GetSubdirectory("exefs"); | 126 | auto exefs_dir = FindSubdirectoryCaseless(subdir, "exefs"); |
| 108 | if (exefs_dir != nullptr) | 127 | if (exefs_dir != nullptr) |
| 109 | layers.push_back(std::move(exefs_dir)); | 128 | layers.push_back(std::move(exefs_dir)); |
| 110 | } | 129 | } |
| @@ -130,7 +149,7 @@ std::vector<VirtualFile> PatchManager::CollectPatches(const std::vector<VirtualD | |||
| 130 | if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) | 149 | if (std::find(disabled.cbegin(), disabled.cend(), subdir->GetName()) != disabled.cend()) |
| 131 | continue; | 150 | continue; |
| 132 | 151 | ||
| 133 | auto exefs_dir = subdir->GetSubdirectory("exefs"); | 152 | auto exefs_dir = FindSubdirectoryCaseless(subdir, "exefs"); |
| 134 | if (exefs_dir != nullptr) { | 153 | if (exefs_dir != nullptr) { |
| 135 | for (const auto& file : exefs_dir->GetFiles()) { | 154 | for (const auto& file : exefs_dir->GetFiles()) { |
| 136 | if (file->GetExtension() == "ips") { | 155 | if (file->GetExtension() == "ips") { |
| @@ -295,7 +314,7 @@ std::vector<Core::Memory::CheatEntry> PatchManager::CreateCheatList( | |||
| 295 | continue; | 314 | continue; |
| 296 | } | 315 | } |
| 297 | 316 | ||
| 298 | auto cheats_dir = subdir->GetSubdirectory("cheats"); | 317 | auto cheats_dir = FindSubdirectoryCaseless(subdir, "cheats"); |
| 299 | if (cheats_dir != nullptr) { | 318 | if (cheats_dir != nullptr) { |
| 300 | auto res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, true); | 319 | auto res = ReadCheatFileFromFolder(system, title_id, build_id_, cheats_dir, true); |
| 301 | if (res.has_value()) { | 320 | if (res.has_value()) { |
| @@ -340,11 +359,11 @@ static void ApplyLayeredFS(VirtualFile& romfs, u64 title_id, ContentRecordType t | |||
| 340 | continue; | 359 | continue; |
| 341 | } | 360 | } |
| 342 | 361 | ||
| 343 | auto romfs_dir = subdir->GetSubdirectory("romfs"); | 362 | auto romfs_dir = FindSubdirectoryCaseless(subdir, "romfs"); |
| 344 | if (romfs_dir != nullptr) | 363 | if (romfs_dir != nullptr) |
| 345 | layers.push_back(std::move(romfs_dir)); | 364 | layers.push_back(std::move(romfs_dir)); |
| 346 | 365 | ||
| 347 | auto ext_dir = subdir->GetSubdirectory("romfs_ext"); | 366 | auto ext_dir = FindSubdirectoryCaseless(subdir, "romfs_ext"); |
| 348 | if (ext_dir != nullptr) | 367 | if (ext_dir != nullptr) |
| 349 | layers_ext.push_back(std::move(ext_dir)); | 368 | layers_ext.push_back(std::move(ext_dir)); |
| 350 | } | 369 | } |
| @@ -470,7 +489,7 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 470 | for (const auto& mod : mod_dir->GetSubdirectories()) { | 489 | for (const auto& mod : mod_dir->GetSubdirectories()) { |
| 471 | std::string types; | 490 | std::string types; |
| 472 | 491 | ||
| 473 | const auto exefs_dir = mod->GetSubdirectory("exefs"); | 492 | const auto exefs_dir = FindSubdirectoryCaseless(mod, "exefs"); |
| 474 | if (IsDirValidAndNonEmpty(exefs_dir)) { | 493 | if (IsDirValidAndNonEmpty(exefs_dir)) { |
| 475 | bool ips = false; | 494 | bool ips = false; |
| 476 | bool ipswitch = false; | 495 | bool ipswitch = false; |
| @@ -494,9 +513,9 @@ std::map<std::string, std::string, std::less<>> PatchManager::GetPatchVersionNam | |||
| 494 | if (layeredfs) | 513 | if (layeredfs) |
| 495 | AppendCommaIfNotEmpty(types, "LayeredExeFS"); | 514 | AppendCommaIfNotEmpty(types, "LayeredExeFS"); |
| 496 | } | 515 | } |
| 497 | if (IsDirValidAndNonEmpty(mod->GetSubdirectory("romfs"))) | 516 | if (IsDirValidAndNonEmpty(FindSubdirectoryCaseless(mod, "romfs"))) |
| 498 | AppendCommaIfNotEmpty(types, "LayeredFS"); | 517 | AppendCommaIfNotEmpty(types, "LayeredFS"); |
| 499 | if (IsDirValidAndNonEmpty(mod->GetSubdirectory("cheats"))) | 518 | if (IsDirValidAndNonEmpty(FindSubdirectoryCaseless(mod, "cheats"))) |
| 500 | AppendCommaIfNotEmpty(types, "Cheats"); | 519 | AppendCommaIfNotEmpty(types, "Cheats"); |
| 501 | 520 | ||
| 502 | if (types.empty()) | 521 | if (types.empty()) |
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index ec6db524d..a1fb6694d 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 | const std::string& 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: |