summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/VolumeDirectory.cpp
diff options
context:
space:
mode:
authorDwayne Slater <ds84182@gmail.com>2017-04-15 13:53:53 -0400
committerDwayne Slater <ds84182@gmail.com>2017-04-15 13:53:53 -0400
commitd3e9569cf0d74fe70a2ce04fc448d5d8d7cfe938 (patch)
treee6c589cb55b2b50b65b7d1784e0e36195869e44a /Source/Core/DiscIO/VolumeDirectory.cpp
parent790830278249c5059d3fef92ea5dfa707de8a0bd (diff)
VolumeDirectory: Compare case-insensitive file names as uppercase, not lowercase
Fixes file ordering in games that use ASCII characters between lowercase 'z' and uppercase 'A' (underscores). MySims Kingdom has the files "terrainLightMapTinted.shader", "terrainLightMapTintedGrid.shader", and "terrainLightMapTinted_no_shadow.shader". In lowercase, "terrainLightMapTinted_no_shadow.shader" comes before "terrainLightMapTinted.shader" and "terrainLightMapTintedGrid.shader", which is invalid.
Diffstat (limited to 'Source/Core/DiscIO/VolumeDirectory.cpp')
-rw-r--r--Source/Core/DiscIO/VolumeDirectory.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp
index 7f552e4195..b2ffe7f98d 100644
--- a/Source/Core/DiscIO/VolumeDirectory.cpp
+++ b/Source/Core/DiscIO/VolumeDirectory.cpp
@@ -25,7 +25,7 @@
namespace DiscIO
{
static u32 ComputeNameSize(const File::FSTEntry& parent_entry);
-static std::string ASCIIToLowercase(std::string str);
+static std::string ASCIIToUppercase(std::string str);
const size_t CVolumeDirectory::MAX_NAME_LENGTH;
const size_t CVolumeDirectory::MAX_ID_LENGTH;
@@ -455,9 +455,9 @@ void CVolumeDirectory::WriteDirectory(const File::FSTEntry& parent_entry, u32* f
// Sort for determinism
std::sort(sorted_entries.begin(), sorted_entries.end(), [](const File::FSTEntry& one,
const File::FSTEntry& two) {
- const std::string one_lower = ASCIIToLowercase(one.virtualName);
- const std::string two_lower = ASCIIToLowercase(two.virtualName);
- return one_lower == two_lower ? one.virtualName < two.virtualName : one_lower < two_lower;
+ const std::string one_upper = ASCIIToUppercase(one.virtualName);
+ const std::string two_upper = ASCIIToUppercase(two.virtualName);
+ return one_upper == two_upper ? one.virtualName < two.virtualName : one_upper < two_upper;
});
for (const File::FSTEntry& entry : sorted_entries)
@@ -500,10 +500,10 @@ static u32 ComputeNameSize(const File::FSTEntry& parent_entry)
return name_size;
}
-static std::string ASCIIToLowercase(std::string str)
+static std::string ASCIIToUppercase(std::string str)
{
std::transform(str.begin(), str.end(), str.begin(),
- [](char c) { return std::tolower(c, std::locale::classic()); });
+ [](char c) { return std::toupper(c, std::locale::classic()); });
return str;
}