Spaces need to be escaped in any system() calls, so we have this simple function which escapes spaces with either doublequotes (Windows style) or backslashes (UNIX style).
Signed-off-by: Steven Noonan <steven@uplinklabs.net>
W3SLCJKEIIRL6WSWYSN5ATZ5XC4GPJLKHGR37AEOZQNO6AQ2HGEAC
}
std::string &escape_path_spaces(std::string &s)
{
std::string result;
result.clear();
#ifdef UNIX
for (const char* ch = s.c_str(); *ch != '\0'; ++ch)
{
if (*ch == ' ')
{
result += '\\';
}
result += *ch;
}
#elif defined(WIN32CONSOLE) || defined(WIN32TILES)
if (s.find(" ") != std::string::npos &&
s.find("\"") == std::string::npos)
{
result = "\"" + s + "\"";
} else {
return s;
}
#else
// Not implemented for this platform. Assume that
// escaping isn't necessary.
return s;
#endif
s = result;
return s;