From: Jarkko Hietaniemi Date: Wed, 24 Oct 2001 12:14:03 +0000 (+0000) Subject: Integrate change #12615 from maintperl; X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b3122bc4daf8abd219740b0090a596d8cd89f890;p=p5sagit%2Fp5-mst-13.2.git Integrate change #12615 from maintperl; on Windows, IO::File::new_tmpfile() fails after being called 32767 times because MSVCRT thinks stdio's TMP_MAX is a process-wide limit p4raw-link: @12615 on //depot/maint-5.6/perl: aaa8dcf5c10a122f8e1febf7ba3d2e8c082c175b p4raw-id: //depot/perl@12618 p4raw-integrated: from //depot/maint-5.6/perl@12617 'merge in' win32/win32.c (@12559..) --- diff --git a/win32/win32.c b/win32/win32.c index 3ebf182..69b7264 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2320,7 +2320,31 @@ win32_rewind(FILE *pf) DllExport FILE* win32_tmpfile(void) { - return tmpfile(); + dTHX; + char prefix[MAX_PATH+1]; + char filename[MAX_PATH+1]; + DWORD len = GetTempPath(MAX_PATH, prefix); + if (len && len < MAX_PATH) { + if (GetTempFileName(prefix, "plx", 0, filename)) { + HANDLE fh = CreateFile(filename, + DELETE | GENERIC_READ | GENERIC_WRITE, + 0, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL + | FILE_FLAG_DELETE_ON_CLOSE, + NULL); + if (fh != INVALID_HANDLE_VALUE) { + int fd = win32_open_osfhandle((long)fh, 0); + if (fd >= 0) { + DEBUG_p(PerlIO_printf(Perl_debug_log, + "Created tmpfile=%s\n",filename)); + return fdopen(fd, "w+b"); + } + } + } + } + return NULL; } DllExport void