ENH: Using GetTempPath instead of TEMP environment variable to get a location to write the Win9x forwarding executable.
This commit is contained in:
parent
33566642a0
commit
179abe7ffe
@ -247,25 +247,19 @@ kwsysProcess* kwsysProcess_New()
|
|||||||
char tempDir[_MAX_PATH+1] = "";
|
char tempDir[_MAX_PATH+1] = "";
|
||||||
|
|
||||||
/* We will try putting the executable in the system temp
|
/* We will try putting the executable in the system temp
|
||||||
directory. */
|
directory. Note that the returned path already has a trailing
|
||||||
DWORD length = GetEnvironmentVariable("TEMP", tempDir, _MAX_PATH);
|
slash. */
|
||||||
|
DWORD length = GetTempPath(_MAX_PATH+1, tempDir);
|
||||||
|
|
||||||
/* Construct the executable name from the process id and kwsysProcess
|
/* Construct the executable name from the process id and kwsysProcess
|
||||||
instance. This should be unique. */
|
instance. This should be unique. */
|
||||||
sprintf(fwdName, "cmw9xfwd_%u_%p.exe", GetCurrentProcessId(), cp);
|
sprintf(fwdName, "cmw9xfwd_%u_%p.exe", GetCurrentProcessId(), cp);
|
||||||
|
|
||||||
/* If the environment variable "TEMP" gave us a directory, use it. */
|
/* If we have a temp directory, use it. */
|
||||||
if(length > 0 && length <= _MAX_PATH)
|
if(length > 0 && length <= _MAX_PATH)
|
||||||
{
|
{
|
||||||
/* Make sure there is no trailing slash. */
|
|
||||||
size_t tdlen = strlen(tempDir);
|
|
||||||
if(tempDir[tdlen-1] == '/' || tempDir[tdlen-1] == '\\')
|
|
||||||
{
|
|
||||||
tempDir[tdlen-1] = 0;
|
|
||||||
--tdlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate a buffer to hold the forwarding executable path. */
|
/* Allocate a buffer to hold the forwarding executable path. */
|
||||||
|
size_t tdlen = strlen(tempDir);
|
||||||
win9x = (char*)malloc(tdlen + strlen(fwdName) + 2);
|
win9x = (char*)malloc(tdlen + strlen(fwdName) + 2);
|
||||||
if(!win9x)
|
if(!win9x)
|
||||||
{
|
{
|
||||||
@ -274,7 +268,7 @@ kwsysProcess* kwsysProcess_New()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Construct the full path to the forwarding executable. */
|
/* Construct the full path to the forwarding executable. */
|
||||||
sprintf(win9x, "%s/%s", tempDir, fwdName);
|
sprintf(win9x, "%s%s", tempDir, fwdName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we found a place to put the forwarding executable, try to
|
/* If we found a place to put the forwarding executable, try to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user