mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-10 03:54:54 -06:00
Core: LocalProcess with args - win32 implementation
git-svn-id: svn://ultimatepp.org/upp/trunk@8068 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
176432a7b6
commit
b6a3c83494
1 changed files with 37 additions and 0 deletions
|
|
@ -110,6 +110,43 @@ bool LocalProcess::DoStart(const char *command, const Vector<String> *arg, bool
|
|||
si.hStdInput = hInputRead;
|
||||
si.hStdOutput = hOutputWrite;
|
||||
si.hStdError = hErrorWrite;
|
||||
String cmdh;
|
||||
if(arg) {
|
||||
cmdh = command;
|
||||
for(int i = 0; i < arg->GetCount(); i++) {
|
||||
cmdh << ' ';
|
||||
String argument = (*arg)[i];
|
||||
if(argument.GetCount() && argument.FindFirstOf(" \t\n\v\"") < 0)
|
||||
cmdh << argument;
|
||||
else {
|
||||
cmdh << '\"';
|
||||
const char *s = argument;
|
||||
for(;;) {
|
||||
int num_backslashes = 0;
|
||||
while(*s == '\\') {
|
||||
s++;
|
||||
num_backslashes++;
|
||||
}
|
||||
if(*s == '\0') {
|
||||
cmdh.Cat('\\', 2 * num_backslashes);
|
||||
break;
|
||||
}
|
||||
else
|
||||
if(*s == '\"') {
|
||||
cmdh.Cat('\\', 2 * num_backslashes + 1);
|
||||
cmdh << '\"';
|
||||
}
|
||||
else {
|
||||
cmdh.Cat('\\', num_backslashes);
|
||||
cmdh.Cat(*s);
|
||||
}
|
||||
s++;
|
||||
}
|
||||
cmdh << '\"';
|
||||
}
|
||||
}
|
||||
command = cmdh;
|
||||
}
|
||||
int n = (int)strlen(command) + 1;
|
||||
Buffer<char> cmd(n);
|
||||
memcpy(cmd, command, n);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue