The mail to wine-devel should have gone to wine-patches Changelog: dlls/msvcrt/file.c: _tempnam Follow documented searchpath for directory. Return with no file created LT Switchercad installation passes NULL as dir-argument. Xilinc _pn.exe relies on a _mkdir call succeeding immediatly after the _tempnam call. -- 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.39 diff -u -r1.39 file.c --- wine/dlls/msvcrt/file.c 17 Sep 2002 18:32:53 -0000 1.39 +++ wine/dlls/msvcrt/file.c 19 Oct 2002 13:37:18 -0000 @@ -1274,15 +1274,32 @@ 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; +#else + if ( (GetEnvironmentVariableA("PWD",dirname,MAX_PATH) ) + && (GetTempFileNameA(dirname,prefix,0,tmpbuf))) + goto done; +#endif + TRACE("failed (%ld)\n",GetLastError()); return NULL; + + done: + TRACE("got name (%s)\n",tmpbuf); + DeleteFileA(tmpbuf); + return _strdup(tmpbuf); + } /********************************************************************* @@ -1291,16 +1308,36 @@ WCHAR *_wtempnam(const WCHAR *dir, const WCHAR *prefix) { WCHAR 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); - } TRACE("failed (%ld)\n",GetLastError()); return NULL; -} + 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; +#else + if ( (GetEnvironmentVariableW(pwd_env,dirname,MAX_PATH) ) + && (GetTempFileNameW(dirname,prefix,0,tmpbuf))) + goto done; +#endif + + TRACE("failed (%ld)\n",GetLastError()); + DeleteFileW(tmpbuf); + return NULL; + +done: + TRACE("got name (%s)\n",debugstr_w(tmpbuf)); + return _wcsdup(tmpbuf); + } /********************************************************************* * _umask (MSVCRT.@)