mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 01:25:38 +00:00
Escape %ROM% by putting everything in quotes on Windows.
Use backslashes in %ROM% and %ROM_RAW% on Windows.
This commit is contained in:
parent
1de0b888aa
commit
1500edbde3
|
@ -70,11 +70,17 @@ std::string strreplace(std::string str, const std::string& replace, const std::s
|
|||
return str;
|
||||
}
|
||||
|
||||
// plaform-specific escape path function
|
||||
// on windows: just puts the path in quotes
|
||||
// everything else: assume bash and escape special characters with backslashes
|
||||
std::string escapePath(const boost::filesystem::path& path)
|
||||
{
|
||||
// a quick and dirty way to insert a backslash before most characters that would mess up a bash path;
|
||||
// someone with regex knowledge should make this into a one-liner
|
||||
std::string pathStr = path.generic_string();
|
||||
#ifdef _WIN32
|
||||
// windows escapes stuff by just putting everything in quotes
|
||||
return '"' + fs::path(path).make_preferred().string() + '"';
|
||||
#else
|
||||
// a quick and dirty way to insert a backslash before most characters that would mess up a bash path
|
||||
std::string pathStr = path.string();
|
||||
|
||||
const char* invalidChars = " '\"\\!$^&*(){}[]?;<>";
|
||||
for(unsigned int i = 0; i < pathStr.length(); i++)
|
||||
|
@ -94,6 +100,7 @@ std::string escapePath(const boost::filesystem::path& path)
|
|||
}
|
||||
|
||||
return pathStr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SystemData::launchGame(Window* window, FileData* game)
|
||||
|
@ -108,7 +115,7 @@ void SystemData::launchGame(Window* window, FileData* game)
|
|||
|
||||
const std::string rom = escapePath(game->getPath());
|
||||
const std::string basename = game->getPath().stem().string();
|
||||
const std::string rom_raw = game->getPath().string();
|
||||
const std::string rom_raw = fs::path(game->getPath()).make_preferred().string();
|
||||
|
||||
command = strreplace(command, "%ROM%", rom);
|
||||
command = strreplace(command, "%BASENAME%", basename);
|
||||
|
|
Loading…
Reference in a new issue