diff options
| author | Léo Lam <leo@leolam.fr> | 2022-01-17 11:43:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-17 11:43:50 +0100 |
| commit | b7e55e2d52e181b2943a337c8ddc7e6021819935 (patch) | |
| tree | c55774af52802324951f27b5b1eea616303fb95a /Source/Core/DiscIO | |
| parent | e62771856092cd9bbc25c8c94c433ed0e55a9f3f (diff) | |
| parent | 43e146a1d5c327d49fdacddb7a5a7e7f0307fab8 (diff) | |
Merge pull request #10368 from Pokechu22/gamelist-lowercase-extension
GameList: Convert file extensions to lowercase
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/DirectoryBlob.cpp | 14 | ||||
| -rw-r--r-- | Source/Core/DiscIO/FileSystemGCWii.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/DiscIO/RiivolutionPatcher.cpp | 6 |
3 files changed, 8 insertions, 20 deletions
diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index 80bd173ae0..e5a3601758 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -1132,8 +1132,10 @@ void DirectoryBlobPartition::WriteDirectory(std::vector<FSTBuilderNode>* parent_ // Sort for determinism std::sort(sorted_entries.begin(), sorted_entries.end(), [](const FSTBuilderNode& one, const FSTBuilderNode& two) { - const std::string one_upper = ASCIIToUppercase(one.m_filename); - const std::string two_upper = ASCIIToUppercase(two.m_filename); + std::string one_upper = one.m_filename; + std::string two_upper = two.m_filename; + Common::ToUpper(&one_upper); + Common::ToUpper(&two_upper); return one_upper == two_upper ? one.m_filename < two.m_filename : one_upper < two_upper; }); @@ -1199,12 +1201,4 @@ static void Write32(u32 data, u32 offset, std::vector<u8>* buffer) (*buffer)[offset++] = (data >> 8) & 0xff; (*buffer)[offset] = data & 0xff; } - -static std::string ASCIIToUppercase(std::string str) -{ - std::transform(str.begin(), str.end(), str.begin(), - [](char c) { return std::toupper(c, std::locale::classic()); }); - return str; -} - } // namespace DiscIO diff --git a/Source/Core/DiscIO/FileSystemGCWii.cpp b/Source/Core/DiscIO/FileSystemGCWii.cpp index ed4c11d9a8..4090a9882d 100644 --- a/Source/Core/DiscIO/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/FileSystemGCWii.cpp @@ -146,13 +146,9 @@ bool FileInfoGCWii::NameCaseInsensitiveEquals(std::string_view other) const // other is in UTF-8 and this is in Shift-JIS, so we convert so that we can compare correctly const std::string this_utf8 = SHIFTJISToUTF8(this_ptr); return std::equal(this_utf8.cbegin(), this_utf8.cend(), other.cbegin() + i, other.cend(), - [](char a, char b) { - return std::tolower(a, std::locale::classic()) == - std::tolower(b, std::locale::classic()); - }); + [](char a, char b) { return Common::ToLower(a) == Common::ToLower(b); }); } - else if (std::tolower(*this_ptr, std::locale::classic()) != - std::tolower(*other_ptr, std::locale::classic())) + else if (Common::ToLower(*this_ptr) != Common::ToLower(*other_ptr)) { return false; } diff --git a/Source/Core/DiscIO/RiivolutionPatcher.cpp b/Source/Core/DiscIO/RiivolutionPatcher.cpp index 384e07680f..e3d3d88af9 100644 --- a/Source/Core/DiscIO/RiivolutionPatcher.cpp +++ b/Source/Core/DiscIO/RiivolutionPatcher.cpp @@ -4,7 +4,6 @@ #include "DiscIO/RiivolutionPatcher.h" #include <algorithm> -#include <cctype> #include <locale> #include <string> #include <string_view> @@ -324,9 +323,8 @@ static bool CaseInsensitiveEquals(std::string_view a, std::string_view b) { if (a.size() != b.size()) return false; - return std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) { - return std::tolower(ca, std::locale::classic()) == std::tolower(cb, std::locale::classic()); - }); + return std::equal(a.begin(), a.end(), b.begin(), + [](char ca, char cb) { return Common::ToLower(ca) == Common::ToLower(cb); }); } static FSTBuilderNode* FindFileNodeInFST(std::string_view path, std::vector<FSTBuilderNode>* fst, |
