On Win32 you can use the environment variables TMP and TEMP to obtain the directory for temporary files. For portability of applications it makes a great deal of sense (especially when documenting your application!) if the same overrides for temporary file placement is checked in the same order on every platform.
Note that this change is backwards compatible in the sense that absent any overrides the placement of temporary files is the default for each platform. Index: main/php_open_temporary_file.c =================================================================== RCS file: /repository/php4/main/php_open_temporary_file.c,v retrieving revision 1.14 diff -u -b -r1.14 php_open_temporary_file.c --- main/php_open_temporary_file.c 28 Feb 2002 08:27:03 -0000 1.14 +++ main/php_open_temporary_file.c 30 Apr 2002 13:56:36 -0000 @@ -150,47 +150,40 @@ */ PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, char **opened_path_p TSRMLS_DC) { - static char path_tmp[] = "/tmp"; - FILE *fp; - - + FILE* fp = 0; if (!pfx) { pfx = "tmp."; } - if (opened_path_p) { *opened_path_p = NULL; } - - if ((fp=php_do_open_temporary_file((char *) dir, pfx, opened_path_p TSRMLS_CC))) { + fp = php_do_open_temporary_file((char *) dir, pfx, opened_path_p TSRMLS_CC); + if (fp) { return fp; } - - if ((fp=php_do_open_temporary_file(getenv("TMPDIR"), pfx, opened_path_p TSRMLS_CC))) { + fp = php_do_open_temporary_file(getenv("TMPDIR"), pfx, opened_path_p TSRMLS_CC); + if (fp) { return fp; } -#if PHP_WIN32 - { - char *TempPath; - - TempPath = (char *) emalloc(MAXPATHLEN); - if (GetTempPath(MAXPATHLEN, TempPath)) { - fp = php_do_open_temporary_file(TempPath, pfx, opened_path_p TSRMLS_CC); - } - efree(TempPath); + fp = php_do_open_temporary_file(getenv("TEMP"), pfx, opened_path_p TSRMLS_CC); + if (fp) { return fp; } -#else - if ((fp=php_do_open_temporary_file(P_tmpdir, pfx, opened_path_p TSRMLS_CC))) { + fp = php_do_open_temporary_file(getenv("TMP"), pfx, opened_path_p TSRMLS_CC); + if (fp) { return fp; } - - if ((fp=php_do_open_temporary_file(path_tmp, pfx, opened_path_p TSRMLS_CC))) { +#ifdef P_tmpdir + fp = php_do_open_temporary_file(P_tmpdir, pfx, opened_path_p TSRMLS_CC); + if (fp) { return fp; } #endif - - return NULL; + fp = php_do_open_temporary_file("/tmp", pfx, opened_path_p TSRMLS_CC); + if (fp) { + return fp; + } + return 0; } /* }}} */ -- Preston L. Bannister http://members.cox.net/preston.bannister/ pbannister on Yahoo Messenger -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php