1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Simplify EscapePathForShell by using std functions.

This commit is contained in:
Aaron van Geffen
2018-09-13 22:31:05 +02:00
parent e84348309c
commit e1d6585423

View File

@@ -377,27 +377,13 @@ namespace OpenRCT2::Ui
throw std::runtime_error(dialogMissingWarning);
}
static std::string EscapePathForShell(const std::string& path)
static std::string EscapePathForShell(std::string path)
{
char output[256] = { 0 };
char* outputPtr = output;
*outputPtr = '"';
outputPtr++;
for (uint32_t i = 0; i < path.length(); i++)
for (size_t index = 0; (index = path.find('"', index)) != std::string::npos; index += 2)
{
if (path[i] == '"')
{
*outputPtr = '\\';
outputPtr++;
}
*outputPtr = path[i];
outputPtr++;
path.replace(index, 1, "\\\"");
}
*outputPtr = '"';
return std::string(output);
return '"' + path + '"';
}
};