From 99f73304750eac9098cc7f9f9ba33d44db3e7222 Mon Sep 17 00:00:00 2001 From: John Rassa Date: Wed, 11 Apr 2018 20:17:58 -0700 Subject: [PATCH] fix for several small issues in Windows build --- es-app/src/CollectionSystemManager.cpp | 7 +++---- es-app/src/FileData.cpp | 2 +- es-core/src/utils/FileSystemUtil.cpp | 14 +++++++++++++- es-core/src/utils/FileSystemUtil.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index b359dc45a..2d2673bee 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -973,8 +973,7 @@ std::vector CollectionSystemManager::getCollectionsFromConfigFolder if (Utils::FileSystem::isRegularFile(*it)) { // it's a file - std::string file = *it; - std::string filename = file.substr(configPath.size()); + std::string filename = Utils::FileSystem::getFileName(*it); // need to confirm filename matches config format if (filename != "custom-.cfg" && Utils::String::startsWith(filename, "custom-") && Utils::String::endsWith(filename, ".cfg")) @@ -1041,7 +1040,7 @@ std::string getCustomCollectionConfigPath(std::string collectionName) std::string getCollectionsFolder() { - return Utils::FileSystem::getHomePath() + "/.emulationstation/collections/"; + return Utils::FileSystem::getGenericPath(Utils::FileSystem::getHomePath() + "/.emulationstation/collections/"); } bool systemSort(SystemData* sys1, SystemData* sys2) @@ -1049,4 +1048,4 @@ bool systemSort(SystemData* sys1, SystemData* sys2) std::string name1 = Utils::String::toUpper(sys1->getName()); std::string name2 = Utils::String::toUpper(sys2->getName()); return name1.compare(name2) < 0; -} \ No newline at end of file +} diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index be7dd0d84..9d87823e8 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -258,7 +258,7 @@ void FileData::launchGame(Window* window) const std::string rom = Utils::FileSystem::getEscapedPath(getPath()); const std::string basename = Utils::FileSystem::getStem(getPath()); - const std::string rom_raw = getPath(); + const std::string rom_raw = Utils::FileSystem::getPreferredPath(getPath()); command = Utils::String::replace(command, "%ROM%", rom); command = Utils::String::replace(command, "%BASENAME%", basename); diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index fdb2ad3da..23234ee07 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -197,6 +197,18 @@ namespace Utils } // getExePath + std::string getPreferredPath(const std::string& _path) + { + std::string path = _path; + size_t offset = std::string::npos; +#if defined(_WIN32) + // convert '/' to '\\' + while((offset = path.find('/')) != std::string::npos) + path.replace(offset, 1, "\\"); +#endif // _WIN32 + return path; + } + std::string getGenericPath(const std::string& _path) { std::string path = _path; @@ -225,7 +237,7 @@ namespace Utils #if defined(_WIN32) // windows escapes stuff by just putting everything in quotes - return '"' + path + '"'; + return '"' + getPreferredPath(path) + '"'; #else // _WIN32 // insert a backslash before most characters that would mess up a bash path const char* invalidChars = "\\ '\"!$^&*(){}[]?;<>"; diff --git a/es-core/src/utils/FileSystemUtil.h b/es-core/src/utils/FileSystemUtil.h index 8a23bc9c6..bb71f7b7c 100644 --- a/es-core/src/utils/FileSystemUtil.h +++ b/es-core/src/utils/FileSystemUtil.h @@ -16,6 +16,7 @@ namespace Utils std::string getHomePath (); std::string getCWDPath (); std::string getExePath (); + std::string getPreferredPath (const std::string& _path); std::string getGenericPath (const std::string& _path); std::string getEscapedPath (const std::string& _path); std::string getCanonicalPath (const std::string& _path);