Change 12618 by jhi@alpha on 2001/10/24 12:14:03

        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

Affected files ...

... //depot/perl/win32/win32.c#172 integrate

Differences ...

==== //depot/perl/win32/win32.c#172 (text) ====
Index: perl/win32/win32.c
--- perl/win32/win32.c.~1~      Wed Oct 24 06:30:05 2001
+++ perl/win32/win32.c  Wed Oct 24 06:30:05 2001
@@ -2320,7 +2320,31 @@
 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
End of Patch.

Reply via email to