diff options
author | Willem Jan Palenstijn | 2015-07-22 22:37:40 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-07-22 22:43:42 +0200 |
commit | 6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch) | |
tree | 503d50902bad2d800165593039d08d5ccf0c98ab /engines/zvision/file/search_manager.cpp | |
parent | 5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff) | |
parent | 4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff) | |
download | scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2 scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip |
Merge branch 'master' into mm
Conflicts:
engines/access/access.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/martian/martian_game.cpp
engines/access/player.cpp
engines/access/player.h
engines/access/resources.cpp
engines/access/screen.cpp
engines/access/screen.h
engines/access/sound.cpp
engines/access/sound.h
Diffstat (limited to 'engines/zvision/file/search_manager.cpp')
-rw-r--r-- | engines/zvision/file/search_manager.cpp | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 30c269c290..821b85b053 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -62,19 +62,6 @@ SearchManager::~SearchManager() { _archList.clear(); } -void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { - Common::String lowerCaseName = dst; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator it = _files.find(lowerCaseName); - - if (it != _files.end()) { - lowerCaseName = src; - lowerCaseName.toLowercase(); - _files[lowerCaseName] = it->_value; - } -} - void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { bool addArch = true; Common::List<Common::Archive *>::iterator it = _archList.begin(); @@ -147,9 +134,10 @@ bool SearchManager::hasFile(const Common::String &name) { return false; } -void SearchManager::loadZix(const Common::String &name) { +bool SearchManager::loadZix(const Common::String &name) { Common::File file; - file.open(name); + if (!file.open(name)) + return false; Common::String line; @@ -160,7 +148,7 @@ void SearchManager::loadZix(const Common::String &name) { } if (file.eos()) - return; + error("Corrupt ZIX file: %s", name.c_str()); Common::Array<Common::Archive *> archives; @@ -169,37 +157,47 @@ void SearchManager::loadZix(const Common::String &name) { line.trim(); if (line.matchString("----------*", true)) break; - else if (line.matchString("DIR:*", true)) { - Common::String path(line.c_str() + 5); + else if (line.matchString("DIR:*", true) || line.matchString("CD0:*", true) || line.matchString("CD1:*", true) || line.matchString("CD2:*", true)) { Common::Archive *arc; - char tempPath[128]; - strcpy(tempPath, path.c_str()); + + Common::String path(line.c_str() + 5); for (uint i = 0; i < path.size(); i++) - if (tempPath[i] == '\\') - tempPath[i] = '/'; + if (path[i] == '\\') + path.setChar('/', i); + + // Check if NEMESIS.ZIX/MEDIUM.ZIX refers to the znemesis folder, and + // check the game root folder instead + if (path.hasPrefix("znemesis/")) + path = Common::String(path.c_str() + 9); + + // Check if INQUIS.ZIX refers to the ZGI folder, and check the game + // root folder instead + if (path.hasPrefix("zgi/")) + path = Common::String(path.c_str() + 4); + if (path.hasPrefix("zgi_e/")) + path = Common::String(path.c_str() + 6); - path = Common::String(tempPath); if (path.size() && path[0] == '.') path.deleteChar(0); if (path.size() && path[0] == '/') path.deleteChar(0); - - if (path.matchString("*.zfs", true)) - arc = new ZfsArchive(path); - else { - if (path.size()) { - if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') - path.deleteLastChar(); - if (path.size()) - for (Common::List<Common::String>::iterator it = _dirList.begin(); it != _dirList.end(); ++it) - if (path.equalsIgnoreCase(*it)) { - path = *it; - break; - } + if (path.size() && path.hasSuffix("/")) + path.deleteLastChar(); + + // Handle paths in case-sensitive file systems (bug #6775) + if (path.size()) { + for (Common::List<Common::String>::iterator it = _dirList.begin(); it != _dirList.end(); ++it) { + if (path.equalsIgnoreCase(*it)) { + path = *it; + break; + } } + } + if (path.matchString("*.zfs", true)) { + arc = new ZfsArchive(path); + } else { path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); - arc = new Common::FSDirectory(path); } archives.push_back(arc); @@ -207,7 +205,7 @@ void SearchManager::loadZix(const Common::String &name) { } if (file.eos()) - return; + error("Corrupt ZIX file: %s", name.c_str()); while (!file.eos()) { line = file.readLine(); @@ -220,6 +218,8 @@ void SearchManager::loadZix(const Common::String &name) { } } } + + return true; } void SearchManager::addDir(const Common::String &name) { @@ -265,7 +265,7 @@ void SearchManager::addDir(const Common::String &name) { void SearchManager::listDirRecursive(Common::List<Common::String> &_list, const Common::FSNode &fsNode, int depth) { Common::FSList fsList; - if ( fsNode.getChildren(fsList) ) { + if (fsNode.getChildren(fsList)) { _list.push_back(fsNode.getPath()); @@ -275,4 +275,11 @@ void SearchManager::listDirRecursive(Common::List<Common::String> &_list, const } } +void SearchManager::listMembersWithExtension(MatchList &fileList, Common::String extension) { + for (SearchManager::MatchList::iterator it = _files.begin(); it != _files.end(); ++it) { + if (it->_key.hasSuffix(extension)) + fileList[it->_key] = it->_value; + } +} + } // End of namespace ZVision |