| 1227 | } |
| 1228 | |
| 1229 | String Utility::EscapeShellArg(const String& s) |
| 1230 | { |
| 1231 | String result; |
| 1232 | |
| 1233 | #ifdef _WIN32 |
| 1234 | result = "\""; |
| 1235 | #else /* _WIN32 */ |
| 1236 | result = "'"; |
| 1237 | #endif /* _WIN32 */ |
| 1238 | |
| 1239 | for (char ch : s) { |
| 1240 | #ifdef _WIN32 |
| 1241 | if (ch == '"' || ch == '%') { |
| 1242 | result += ' '; |
| 1243 | } |
| 1244 | #else /* _WIN32 */ |
| 1245 | if (ch == '\'') |
| 1246 | result += "'\\'"; |
| 1247 | #endif |
| 1248 | result += ch; |
| 1249 | } |
| 1250 | |
| 1251 | #ifdef _WIN32 |
| 1252 | result += '"'; |
| 1253 | #else /* _WIN32 */ |
| 1254 | result += '\''; |
| 1255 | #endif /* _WIN32 */ |
| 1256 | |
| 1257 | return result; |
| 1258 | } |
| 1259 | |
| 1260 | #ifdef _WIN32 |
| 1261 | String Utility::EscapeCreateProcessArg(const String& arg) |
nothing calls this directly
no outgoing calls
no test coverage detected