MCPcopy Create free account
hub / github.com/Icinga/icinga2 / EscapeCreateProcessArg

Method EscapeCreateProcessArg

lib/base/utility.cpp:1261–1291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1259
1260#ifdef _WIN32
1261String 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

Callers

nothing calls this directly

Calls 4

FindFirstOfMethod · 0.80
AppendMethod · 0.80
BeginMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected