diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index 42f3bb6212..f5bbf8e03b 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -795,10 +795,17 @@ static std::string SimulateVFATBug(std::string filename) { // These are the characters allowed in DOS filenames. static const char *FAT_UPPER_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&'(){}-_`~"; static const char *FAT_LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&'(){}-_`~"; + static const char *LOWER_CHARS = "abcdefghijklmnopqrstuvwxyz"; + + // To avoid logging/comparing, skip all this if it has no lowercase chars to begin with. + size_t lowerchar = filename.find_first_of(LOWER_CHARS); + if (lowerchar == filename.npos) { + return filename; + } bool apply_hack = false; size_t dot_pos = filename.find('.'); - if (dot_pos == filename.npos) { + if (dot_pos == filename.npos && filename.length() <= 8) { size_t badchar = filename.find_first_not_of(FAT_LOWER_CHARS); if (badchar == filename.npos) { // It's all lowercase. Convert to upper. @@ -825,6 +832,7 @@ static std::string SimulateVFATBug(std::string filename) { } if (apply_hack) { + VERBOSE_LOG(FILESYS, "Applying VFAT hack to filename: %s", filename.c_str()); // In this situation, NT would write UPPERCASE, and just set a flag to say "actually lowercase". // That VFAT flag isn't read by the PSP firmware, so let's pretend to "not read it." std::transform(filename.begin(), filename.end(), filename.begin(), toupper);