summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-07-07 13:10:08 (GMT)
committerBrad King <brad.king@kitware.com>2003-07-07 13:10:08 (GMT)
commit2b8bfb3b5d152d07f2d9d059b98680f6313b3050 (patch)
tree77033a7a7aa6fcc4188f4122c30eacd9a265730e
parentccc629702caac98d72a654ffda64c1e049bbd9ef (diff)
downloadCMake-2b8bfb3b5d152d07f2d9d059b98680f6313b3050.zip
CMake-2b8bfb3b5d152d07f2d9d059b98680f6313b3050.tar.gz
CMake-2b8bfb3b5d152d07f2d9d059b98680f6313b3050.tar.bz2
ENH: Implemented SetWorkingDirectory method on Windows.
-rw-r--r--Source/kwsys/ProcessWin32.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index f567682..8f7a0d3 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -133,9 +133,12 @@ struct kwsysProcess_s
/* The status of the process. */
int State;
- /* The command line to execute. */
+ /* The command line to execute. */
char* Command;
+ /* The working directory for the child process. */
+ char* WorkingDirectory;
+
/* On Win9x platforms, the path to the forwarding executable. */
char* Win9x;
@@ -417,6 +420,7 @@ void kwsysProcess_Delete(kwsysProcess* cp)
/* Free memory. */
kwsysProcess_SetCommand(cp, 0);
+ kwsysProcess_SetWorkingDirectory(cp, 0);
if(cp->Win9x)
{
_unlink(cp->Win9x);
@@ -607,6 +611,30 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout)
}
/*--------------------------------------------------------------------------*/
+void kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
+{
+ if(cp->WorkingDirectory)
+ {
+ free(cp->WorkingDirectory);
+ cp->WorkingDirectory = 0;
+ }
+ if(dir && dir[0])
+ {
+ /* We must convert the working directory to a full path. */
+ DWORD length = GetFullPathName(dir, 0, 0, 0);
+ if(length > 0)
+ {
+ cp->WorkingDirectory = (char*)malloc(length);
+ if(!GetFullPathName(dir, length, cp->WorkingDirectory, 0))
+ {
+ free(cp->WorkingDirectory);
+ cp->WorkingDirectory = 0;
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------*/
int kwsysProcess_GetState(kwsysProcess* cp)
{
return cp->State;
@@ -749,7 +777,7 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* CREATE THE CHILD PROCESS */
if(!CreateProcess(0, cp->RealCommand, 0, 0, TRUE,
cp->Win9x? CREATE_NEW_CONSOLE:DETACHED_PROCESS, 0,
- 0, &si, &cp->ProcessInformation))
+ cp->WorkingDirectory, &si, &cp->ProcessInformation))
{
kwsysProcessCleanup(cp, 1);
return;