diff --git a/OpenTESArena/src/Assets/CIFFile.cpp b/OpenTESArena/src/Assets/CIFFile.cpp index 02575ca9f..8eeca2270 100644 --- a/OpenTESArena/src/Assets/CIFFile.cpp +++ b/OpenTESArena/src/Assets/CIFFile.cpp @@ -25,7 +25,10 @@ namespace CIFFile::CIFFile(const std::string &filename) { - VFS::IStreamPtr stream = VFS::Manager::get().open(filename); + // Some filenames (i.e., Arrows.cif) have different casing between the floppy version and + // CD version, so this needs to use the case-insensitive open() method for correct behavior + // on Unix-based systems. + VFS::IStreamPtr stream = VFS::Manager::get().openCaseInsensitive(filename); DebugAssert(stream != nullptr, "Could not open \"" + filename + "\"."); stream->seekg(0, std::ios::end); diff --git a/OpenTESArena/src/Assets/INFFile.cpp b/OpenTESArena/src/Assets/INFFile.cpp index 1b9ba250a..08d1b1a23 100644 --- a/OpenTESArena/src/Assets/INFFile.cpp +++ b/OpenTESArena/src/Assets/INFFile.cpp @@ -164,7 +164,10 @@ const int INFFile::NO_INDEX = -1; INFFile::INFFile(const std::string &filename) { - VFS::IStreamPtr stream = VFS::Manager::get().open(filename); + // Some filenames (i.e., Crystal3.inf) have different casing between the floppy version and + // CD version, so this needs to use the case-insensitive open() method for correct behavior + // on Unix-based systems. + VFS::IStreamPtr stream = VFS::Manager::get().openCaseInsensitive(filename); DebugAssert(stream != nullptr, "Could not open \"" + filename + "\"."); stream->seekg(0, std::ios::end); diff --git a/components/vfs/manager.cpp b/components/vfs/manager.cpp index 903b70c93..83e4e53dd 100644 --- a/components/vfs/manager.cpp +++ b/components/vfs/manager.cpp @@ -79,10 +79,11 @@ IStreamPtr Manager::openCaseInsensitive(const std::string &name) // worry about filenames just like it but with different casing. std::string newName = name; - // Case 1: All uppercase. - for (char &c : newName) + // Case 1: upper first character, lower rest. + newName.front() = std::toupper(newName.front()); + for (auto iter = newName.begin() + 1; iter != newName.end(); ++iter) { - c = std::toupper(c); + *iter = std::tolower(*iter); } IStreamPtr stream = this->open(newName); @@ -93,11 +94,10 @@ IStreamPtr Manager::openCaseInsensitive(const std::string &name) } else { - // Case 2: Normal case (upper first character, lower rest). - newName.front() = std::toupper(newName.front()); - for (auto iter = newName.begin() + 1; iter != newName.end(); ++iter) + // Case 2: all uppercase. + for (char &c : newName) { - *iter = std::tolower(*iter); + c = std::toupper(c); } stream = this->open(newName);