"David Sommerseth" <dav...@redhat.com> wrote:

-  /* Try to use %TEMP% or %TMP% */
-  tmpdir = getenv("TEMP");
-  if( !tmpdir ) {
-    tmpdir = getenv("TMP");
+  CLEAR (tmpdir);
+
+  /* Try to use %TEMP%, %TMP% or %SystemRoot%\Temp */
+  envptr = getenv("TEMP");
+  if( envptr ) {
+    return envptr;
  }
-  if( !tmpdir ) {
-    /* Warn if we're using a hard coded path */
-    msg (M_WARN, "Could not find %TEMP% or %TMP% environment variables.  "
-         "Falling back to %s.  Consider to use --tmp-dir", DEFAULT_TMPDIR);
-    tmpdir = DEFAULT_TMPDIR;

Why not a bit simpler; GetTempPath() (kernel32.dll) already does these tests. Ref: http://msdn.microsoft.com/en-us/library/aa364992(v=vs.85).aspx :

The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found:
 1.. The path specified by the TMP environment variable.
 2.. The path specified by the TEMP environment variable.
 3.. The path specified by the USERPROFILE environment variable.
 4.. The Windows directory.

--gv

Reply via email to