diff --git a/engines/ags/ags.cpp b/engines/ags/ags.cpp index 648dfca0242..d1d4b6c7f97 100644 --- a/engines/ags/ags.cpp +++ b/engines/ags/ags.cpp @@ -124,7 +124,7 @@ Common::Error AGSEngine::run() { if (debugChannelSet(-1, kDebugScan)) { // Scan the given folder and subfolders for unknown games AGS3::GameScanner scanner; - scanner.scan(ConfMan.get("path")); + scanner.scan(ConfMan.getPath("path")); return Common::kNoError; } @@ -295,7 +295,7 @@ bool AGSEngine::is64BitGame() const { } Common::FSNode AGSEngine::getGameFolder() { - return Common::FSNode(ConfMan.get("path")); + return Common::FSNode(ConfMan.getPath("path")); } bool AGSEngine::canLoadGameStateCurrently(Common::U32String *msg) { diff --git a/engines/ags/console.cpp b/engines/ags/console.cpp index 02a274d832f..87c74be2372 100644 --- a/engines/ags/console.cpp +++ b/engines/ags/console.cpp @@ -225,7 +225,7 @@ bool AGSConsole::Cmd_dumpSprite(int argc, const char **argv) { return true; } - Common::String pngFile = Common::String::format("%s-sprite%03d.png", _vm->getGameId().c_str(), spriteId); + Common::Path pngFile(Common::String::format("%s-sprite%03d.png", _vm->getGameId().c_str(), spriteId)); Common::DumpFile df; if (df.open(pngFile)) { byte *palette = nullptr; diff --git a/engines/ags/detection.cpp b/engines/ags/detection.cpp index 0424c837538..f6139c73b38 100644 --- a/engines/ags/detection.cpp +++ b/engines/ags/detection.cpp @@ -147,14 +147,14 @@ ADDetectedGame AGSMetaEngineDetection::fallbackDetect(const FileMap &allFiles, c if (file->isDirectory()) continue; - Common::String filename = file->getName(); - if (!filename.hasSuffixIgnoreCase(".exe") && - !filename.hasSuffixIgnoreCase(".ags") && + Common::Path filename = file->getPathInArchive(); + if (!filename.baseName().hasSuffixIgnoreCase(".exe") && + !filename.baseName().hasSuffixIgnoreCase(".ags") && !filename.equalsIgnoreCase("ac2game.dat")) // Neither, so move on continue; - filename = Common::punycode_encodefilename(filename); + filename = filename.punycodeEncode(); Common::File f; if (!allFiles.contains(filename) || !f.open(allFiles[filename])) continue; @@ -177,7 +177,7 @@ ADDetectedGame AGSMetaEngineDetection::fallbackDetect(const FileMap &allFiles, c AGS::g_fallbackDesc.desc.gameId = _gameid.c_str(); AGS::g_fallbackDesc.desc.extra = _extra.c_str(); - AGS::g_fallbackDesc.desc.filesDescriptions[0].fileName = _filename.c_str(); + AGS::g_fallbackDesc.desc.filesDescriptions[0].fileName = _filename.toString('/').c_str(); AGS::g_fallbackDesc.desc.filesDescriptions[0].fileSize = f.size(); AGS::g_fallbackDesc.desc.filesDescriptions[0].md5 = _md5.c_str(); diff --git a/engines/ags/detection.h b/engines/ags/detection.h index e7adc087cdf..6a11772c2dd 100644 --- a/engines/ags/detection.h +++ b/engines/ags/detection.h @@ -67,7 +67,7 @@ enum AGSSpriteFontVersion { kAGSSpriteFont = 0, kClifftopGames = 1 }; class AGSMetaEngineDetection : public AdvancedMetaEngineDetection { mutable Common::String _gameid; mutable Common::String _extra; - mutable Common::String _filename; + mutable Common::Path _filename; mutable Common::String _md5; static const DebugChannelDef debugFlagList[]; diff --git a/engines/ags/dialogs.cpp b/engines/ags/dialogs.cpp index ee0bebb1901..fdd205f112e 100644 --- a/engines/ags/dialogs.cpp +++ b/engines/ags/dialogs.cpp @@ -64,7 +64,7 @@ AGSOptionsWidget::AGSOptionsWidget(GuiObject *boss, const Common::String &name, _langPopUp = new GUI::PopUpWidget(widgetsBoss(), _dialogLayout + ".translation"); _langPopUp->appendEntry(_(""), (uint32) - 1); - Common::String path = ConfMan.get("path", _domain); + Common::Path path = ConfMan.getPath("path", _domain); Common::FSDirectory dir(path); Common::ArchiveMemberList traFileList; dir.listMatchingMembers(traFileList, "*.tra"); diff --git a/engines/ags/engine/ac/listbox.cpp b/engines/ags/engine/ac/listbox.cpp index 0c3a572b06f..daaaa85ecbc 100644 --- a/engines/ags/engine/ac/listbox.cpp +++ b/engines/ags/engine/ac/listbox.cpp @@ -86,7 +86,7 @@ void FillDirList(std::set &files, const String &path) { String subDir = dirName.Mid(_GP(ResPaths).DataDir.GetLength()); if (!subDir.IsEmpty() && subDir[0u] == '/') subDir.ClipLeft(1); - dirName = ConfMan.get("path"); + dirName = ConfMan.getPath("path").toString('/'); } else if (dirName.CompareLeftNoCase(get_save_game_directory()) == 0) { // Save files listing FillSaveList(files, filePattern); diff --git a/engines/ags/game_scanner.cpp b/engines/ags/game_scanner.cpp index 55cb2fd78b9..825b8f967f6 100644 --- a/engines/ags/game_scanner.cpp +++ b/engines/ags/game_scanner.cpp @@ -46,7 +46,7 @@ extern bool define_gamedata_location(const AGS::Shared::String &exe_path); extern bool engine_try_init_gamedata(AGS::Shared::String gamepak_path); -void GameScanner::scan(const Common::String &startFolder) { +void GameScanner::scan(const Common::Path &startFolder) { detectClashes(); Common::FSNode folder(startFolder); @@ -91,13 +91,13 @@ void GameScanner::scanFolder(const Common::FSNode &folder) { } else if (filename.hasSuffixIgnoreCase(".exe") || filename.hasSuffixIgnoreCase(".ags") || filename.equalsIgnoreCase("ac2game.dat")) { - Common::String path = node.getPath(); + Common::Path path = node.getPath(); scanFile(path); } } } -void GameScanner::scanFile(const Common::String &filename) { +void GameScanner::scanFile(const Common::Path &filename) { #ifdef TODO Common::File f; Common::FSNode fsNode(filename); diff --git a/engines/ags/game_scanner.h b/engines/ags/game_scanner.h index e6591812fc0..1d5f60366af 100644 --- a/engines/ags/game_scanner.h +++ b/engines/ags/game_scanner.h @@ -50,7 +50,7 @@ private: /** * Scans a single file that may be an AGS game */ - void scanFile(const Common::String &filename); + void scanFile(const Common::Path &filename); /** * Convert a game name to an appropriate game Id @@ -65,7 +65,7 @@ public: /** * Main execution method */ - void scan(const Common::String &startFolder); + void scan(const Common::Path &startFolder); }; } // namespace AGS3 diff --git a/engines/ags/shared/game/main_game_file.cpp b/engines/ags/shared/game/main_game_file.cpp index f827e815f52..01ed8390957 100644 --- a/engines/ags/shared/game/main_game_file.cpp +++ b/engines/ags/shared/game/main_game_file.cpp @@ -132,12 +132,12 @@ String FindGameData(const String &path, bool(*fn_testfile)(const String &)) { if (folder.getChildren(files, Common::FSNode::kListFilesOnly)) { for (Common::FSList::iterator it = files.begin(); it != files.end(); ++it) { Common::String test_file = it->getName(); - Common::String filePath = it->getPath(); + Common::Path filePath = it->getPath(); if (test_file.hasSuffixIgnoreCase(".ags") || test_file.equalsIgnoreCase("ac2game.dat") || test_file.hasSuffixIgnoreCase(".exe")) { - if (IsMainGameLibrary(test_file.c_str()) && fn_testfile(filePath.c_str())) { + if (IsMainGameLibrary(test_file.c_str()) && fn_testfile(filePath.toString('/'))) { Debug::Printf("Found game data pak: %s", test_file.c_str()); return test_file.c_str(); } diff --git a/engines/ags/shared/util/directory.cpp b/engines/ags/shared/util/directory.cpp index 802033c19ba..dfd970070cf 100644 --- a/engines/ags/shared/util/directory.cpp +++ b/engines/ags/shared/util/directory.cpp @@ -86,7 +86,8 @@ String GetCurrentDirectory() { Path::FixupPath(str); return str; #else - return ConfMan.get("path"); + // Use / separator + return ConfMan.getPath("path").toString('/'); #endif } diff --git a/engines/ags/shared/util/stdio_compat.cpp b/engines/ags/shared/util/stdio_compat.cpp index c6f9d9fdc52..e1fca841892 100644 --- a/engines/ags/shared/util/stdio_compat.cpp +++ b/engines/ags/shared/util/stdio_compat.cpp @@ -54,18 +54,18 @@ static Common::FSNode getFSNode(const char *path) { Common::FSNode node; Common::String filePath(path); if (filePath.empty() || filePath == "." || filePath == "./") - return Common::FSNode(ConfMan.get("path")); + return Common::FSNode(ConfMan.getPath("path")); else if (filePath.hasPrefix("./")) { filePath = filePath.substr(2); - node = Common::FSNode(ConfMan.get("path")); + node = Common::FSNode(ConfMan.getPath("path")); } else if (filePath.hasPrefixIgnoreCase(AGS::Shared::SAVE_FOLDER_PREFIX)) { filePath = filePath.substr(strlen(AGS::Shared::SAVE_FOLDER_PREFIX)); node = Common::FSNode(ConfMan.getPath("savepath")); } else { - node = Common::FSNode(filePath); + node = Common::FSNode(Common::Path(filePath, '/')); if (node.isReadable()) return node; - node = Common::FSNode(ConfMan.get("path")); + node = Common::FSNode(ConfMan.getPath("path")); } // Use FSDirectory for case-insensitive search @@ -74,7 +74,8 @@ static Common::FSNode getFSNode(const char *path) { // Iterate through any further subfolders or filename size_t separator; while ((separator = filePath.find('/')) != Common::String::npos) { - dir.reset(dir->getSubDirectory(filePath.substr(0, separator))); + Common::Path member(filePath.substr(0, separator)); + dir.reset(dir->getSubDirectory(member)); if (!dir) return Common::FSNode(); filePath = Common::String(filePath.c_str() + separator + 1); @@ -83,13 +84,14 @@ static Common::FSNode getFSNode(const char *path) { if (filePath.empty()) return dir->getFSNode(); - if (dir->hasFile(filePath)) { - Common::ArchiveMemberPtr file = dir->getMember(filePath); + Common::Path member(filePath); + if (dir->hasFile(member)) { + Common::ArchiveMemberPtr file = dir->getMember(member); if (file) return dir->getFSNode().getChild(file->getName()); } - Common::FSDirectory *subDir = dir->getSubDirectory(filePath); + Common::FSDirectory *subDir = dir->getSubDirectory(member); if (subDir) { dir.reset(subDir); return dir->getFSNode();