diff options
author | Einar Johan Trøan Sømåen | 2013-02-06 13:40:17 +0100 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2013-02-06 13:40:36 +0100 |
commit | 511f833032ffa27045fbf5ab6422f1f6831afcb7 (patch) | |
tree | 2e568fe7b0909f0de3b062a3577eece83b3d9ac5 | |
parent | 09303f6d1a7c32916e14ee5436b7d7f146c26dc5 (diff) | |
download | scummvm-rg350-511f833032ffa27045fbf5ab6422f1f6831afcb7.tar.gz scummvm-rg350-511f833032ffa27045fbf5ab6422f1f6831afcb7.tar.bz2 scummvm-rg350-511f833032ffa27045fbf5ab6422f1f6831afcb7.zip |
WINTERMUTE: Use case-insensitive path-lookup when opening DiskFiles.
-rw-r--r-- | engines/wintermute/base/file/base_disk_file.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 796531eb27..3c1ecc7a73 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -39,10 +39,10 @@ namespace Wintermute { -void correctSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { +void correctSlashes(Common::String &fileName) { + for (size_t i = 0; i < fileName.size(); i++) { if (fileName[i] == '\\') { - fileName[i] = '/'; + fileName.setChar('/', i); } } } @@ -66,6 +66,12 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { const Common::FSNode gameDataDir(ConfMan.get("path")); Common::FSNode curNode = gameDataDir; + Common::String fixedPath = ""; + while (!path.empty()) { + fixedPath += path.nextToken() + "/"; + } + fixedPath.deleteLastChar(); + // Parse all path-elements while (!path.empty()) { // Get the next path-component by slicing on '\\' @@ -111,11 +117,12 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { uint32 prefixSize = 0; Common::SeekableReadStream *file = nullptr; Common::String fixedFilename = filename; + correctSlashes(fixedFilename); // Absolute path: TODO: Add specific fallbacks here. - if (filename.contains(':')) { - if (filename.hasPrefix("c:\\windows\\fonts\\")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" - fixedFilename = filename.c_str() + 17; + if (fixedFilename.contains(':')) { + if (fixedFilename.hasPrefix("c:/windows/fonts/")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" + fixedFilename = filename.c_str() + 14; } else { error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); } @@ -125,7 +132,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { SearchMan.listMatchingMembers(files, fixedFilename); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { - if ((*it)->getName() == filename) { + if ((*it)->getName().equalsIgnoreCase(lastPathComponent(fixedFilename,'/'))) { file = (*it)->createReadStream(); break; } |