stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Zhong" <Scott.Zh...@roguewave.com>
Subject [PATCH] STDCXX-1019 __rw_mkstemp in file.cpp should honor TMPDIR environment variable
Date Wed, 08 Oct 2008 16:15:14 GMT
https://issues.apache.org/jira/browse/STDCXX-1019

file affected: <stdcxx>/src/file.cpp

Index: src/file.cpp
===================================================================
--- src/file.cpp        (revision 702657)
+++ src/file.cpp        (working copy)
@@ -257,7 +257,9 @@
 #    define P_tmpdir "/tmp"
 #  endif   // P_tmpdir
 
-    char fnamebuf[] = P_tmpdir "/.rwtmpXXXXXX";
+    char *tmpdir = getenv ("TMPDIR") == NULL ? P_tmpdir : getenv
("TMPDIR");
+ 
+    char fnamebuf[] = tmpdir "/.rwtmpXXXXXX";
 
     fd = mkstemp (fnamebuf);
 
@@ -294,7 +296,7 @@
     // names that have no extension. tempnam uses malloc to allocate
     // space for the filename; the program is responsible for freeing
     // this space when it is no longer needed. 
-    char* const fname = tempnam (P_tmpdir, ".rwtmp");
+    char* const fname = tempnam (tmpdir, ".rwtmp");
 
     if (!fname)
         return -1;

Mime
View raw message