msvcrt _tempname (Resent)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog
	dlls/msvcrt/file.c
	Make _tempnam behave like native dll

Test for _wtempnam not yet done.
-- 
Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/msvcrt/file.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/file.c,v
retrieving revision 1.46
diff -u -r1.46 file.c
--- wine/dlls/msvcrt/file.c	11 Jan 2003 21:01:04 -0000	1.46
+++ wine/dlls/msvcrt/file.c	15 Feb 2003 18:39:00 -0000
@@ -1352,15 +1352,31 @@
 char *_tempnam(const char *dir, const char *prefix)
 {
   char tmpbuf[MAX_PATH];
+  char dirname[MAX_PATH];
 
-  TRACE("dir (%s) prefix (%s)\n",dir,prefix);
-  if (GetTempFileNameA(dir,prefix,0,tmpbuf))
-  {
-    TRACE("got name (%s)\n",tmpbuf);
-    return _strdup(tmpbuf);
-  }
+  if ( (GetEnvironmentVariableA("TMP",dirname,MAX_PATH) )
+      && (GetTempFileNameA(dirname,prefix,0,tmpbuf)))
+    goto done;
+  if ( (dir) && lstrcpynA(dirname, dir,MAX_PATH) 
+       && (GetTempFileNameA(dirname,prefix,0,tmpbuf)))
+    goto done;
+#ifdef  P_tmpdir
+  if ( (dir) && lstrcpynA(dirname, P_tmpdir,MAX_PATH) 
+       && (GetTempFileNameA(dirname,prefix,0,tmpbuf)))
+    goto done;
+#endif 
+  if ( (GetEnvironmentVariableA("PWD",dirname,MAX_PATH) )
+      && (GetTempFileNameA(dirname,prefix,0,tmpbuf)))
+    goto done;
+  
   TRACE("failed (%ld)\n",GetLastError());
   return NULL;
+
+ done:
+  TRACE("got name (%s)\n",tmpbuf);
+  DeleteFileA(tmpbuf);
+  return _strdup(tmpbuf);
+
 }
 
 /*********************************************************************
@@ -1369,15 +1385,32 @@
 MSVCRT_wchar_t *_wtempnam(const MSVCRT_wchar_t *dir, const MSVCRT_wchar_t *prefix)
 {
   MSVCRT_wchar_t tmpbuf[MAX_PATH];
+  WCHAR dirname[MAX_PATH];
+  WCHAR tmp_env[] = {'T','M','P',0};
+  WCHAR pwd_env[] = {'P','W','D',0};
 
-  TRACE("dir (%s) prefix (%s)\n",debugstr_w(dir),debugstr_w(prefix));
-  if (GetTempFileNameW(dir,prefix,0,tmpbuf))
-  {
-    TRACE("got name (%s)\n",debugstr_w(tmpbuf));
-    return _wcsdup(tmpbuf);
-  }
+  if ( (GetEnvironmentVariableW(tmp_env,dirname,MAX_PATH) )
+      && (GetTempFileNameW(dirname,prefix,0,tmpbuf)))
+    goto done;
+  if ( (dir) && lstrcpynW(dirname, dir,MAX_PATH) 
+       && (GetTempFileNameW(dirname,prefix,0,tmpbuf)))
+    goto done;
+#ifdef  _wP_tmpdir
+  if ( (dir) && lstrcpynW(dirname, _wP_tmpdir,MAX_PATH) 
+       && (GetTempFileNameW(dirname,prefix,0,tmpbuf)))
+    goto done;
+#endif
+  if ( (GetEnvironmentVariableW(pwd_env,dirname,MAX_PATH) )
+      && (GetTempFileNameW(dirname,prefix,0,tmpbuf)))
+    goto done;
+  
   TRACE("failed (%ld)\n",GetLastError());
+  DeleteFileW(tmpbuf);
   return NULL;
+
+done:
+  TRACE("got name (%s)\n",debugstr_w(tmpbuf));
+  return _wcsdup(tmpbuf);
 }
 
 /*********************************************************************


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux