Change 12615 by gsar@moonru on 2001/10/24 04:09:43
on Windows, IO::File::new_tmpfile() fails after being called
32767 times because MSVCRT thinks stdio's TMP_MAX is a
process-wide limit
Affected files ...
... //depot/maint-5.6/perl/win32/win32.c#23 edit
Differences ...
==== //depot/maint-5.6/perl/win32/win32.c#23 (text) ====
Index: perl/win32/win32.c
--- perl/win32/win32.c.~1~ Tue Oct 23 22:15:05 2001
+++ perl/win32/win32.c Tue Oct 23 22:15:05 2001
@@ -2303,7 +2303,31 @@
DllExport FILE*
win32_tmpfile(void)
{
- return tmpfile();
+ dTHXo;
+ 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
End of Patch.