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;
|
||||
}
|
||||
|
||||
// Change to specified working directory.
|
||||
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
||||
if(dir)
|
||||
{
|
||||
if(cmSystemTools::ChangeDirectory(dir) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
output = "";
|
||||
cmsysProcess* cp = cmsysProcess_New();
|
||||
cmsysProcess_SetCommand(cp, &*argv.begin());
|
||||
cmsysProcess_SetWorkingDirectory(cp, dir);
|
||||
cmsysProcess_Execute(cp);
|
||||
|
||||
char* data;
|
||||
|
@ -420,12 +411,6 @@ bool cmSystemTools::RunCommand(const char* command,
|
|||
|
||||
cmsysProcess_Delete(cp);
|
||||
|
||||
// Restore old working directory.
|
||||
if(dir)
|
||||
{
|
||||
cmSystemTools::ChangeDirectory(cwd.c_str());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue