| 1259 | |
| 1260 | #ifdef _WIN32 |
| 1261 | String Utility::EscapeCreateProcessArg(const String& arg) |
| 1262 | { |
| 1263 | if (arg.FindFirstOf(" \t\n\v\"") == String::NPos) |
| 1264 | return arg; |
| 1265 | |
| 1266 | String result = "\""; |
| 1267 | |
| 1268 | for (String::ConstIterator it = arg.Begin(); ; it++) { |
| 1269 | int numBackslashes = 0; |
| 1270 | |
| 1271 | while (it != arg.End() && *it == '\\') { |
| 1272 | it++; |
| 1273 | numBackslashes++; |
| 1274 | } |
| 1275 | |
| 1276 | if (it == arg.End()) { |
| 1277 | result.Append(numBackslashes * 2, '\\'); |
| 1278 | break; |
| 1279 | } else if (*it == '"') { |
| 1280 | result.Append(numBackslashes * 2 + 1, '\\'); |
| 1281 | result.Append(1, *it); |
| 1282 | } else { |
| 1283 | result.Append(numBackslashes, '\\'); |
| 1284 | result.Append(1, *it); |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | result += "\""; |
| 1289 | |
| 1290 | return result; |
| 1291 | } |
| 1292 | #endif /* _WIN32 */ |
| 1293 | |
| 1294 | #ifdef _WIN32 |
nothing calls this directly
no test coverage detected