From 511f833032ffa27045fbf5ab6422f1f6831afcb7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 6 Feb 2013 13:40:17 +0100 Subject: WINTERMUTE: Use case-insensitive path-lookup when opening DiskFiles. --- engines/wintermute/base/file/base_disk_file.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'engines/wintermute/base/file/base_disk_file.cpp') 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; } -- cgit v1.2.3