Merge pull request #413 from jrassa/windows-fixes

fix for several small issues in Windows build
This commit is contained in:
Jools Wills 2018-04-14 19:52:40 +01:00 committed by GitHub
commit b622a4272e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View file

@ -973,8 +973,7 @@ std::vector<std::string> 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;
}
}

View file

@ -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);

View file

@ -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 = "\\ '\"!$^&*(){}[]?;<>";

View file

@ -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);