ENH: Using new Process SetWorkingDirectory method instead of manually implementing it.
This commit is contained in:
parent
b5fec4a3c8
commit
7479303e01
|
@ -378,19 +378,10 @@ bool cmSystemTools::RunCommand(const char* command,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change to specified working directory.
|
|
||||||
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
|
||||||
if(dir)
|
|
||||||
{
|
|
||||||
if(cmSystemTools::ChangeDirectory(dir) < 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
output = "";
|
output = "";
|
||||||
cmsysProcess* cp = cmsysProcess_New();
|
cmsysProcess* cp = cmsysProcess_New();
|
||||||
cmsysProcess_SetCommand(cp, &*argv.begin());
|
cmsysProcess_SetCommand(cp, &*argv.begin());
|
||||||
|
cmsysProcess_SetWorkingDirectory(cp, dir);
|
||||||
cmsysProcess_Execute(cp);
|
cmsysProcess_Execute(cp);
|
||||||
|
|
||||||
char* data;
|
char* data;
|
||||||
|
@ -420,12 +411,6 @@ bool cmSystemTools::RunCommand(const char* command,
|
||||||
|
|
||||||
cmsysProcess_Delete(cp);
|
cmsysProcess_Delete(cp);
|
||||||
|
|
||||||
// Restore old working directory.
|
|
||||||
if(dir)
|
|
||||||
{
|
|
||||||
cmSystemTools::ChangeDirectory(cwd.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue