summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-10-24 12:14:03 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-10-24 12:14:03 +0000
commitb3122bc4daf8abd219740b0090a596d8cd89f890 (patch)
treeda962c6805902b7c2ec9866180ba7bf294a69df3 /win32
parent3de7a4ec7f37be853bf2c12b0f42e46cb3efb4ff (diff)
downloadperl-b3122bc4daf8abd219740b0090a596d8cd89f890.tar.gz
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..)
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 3ebf182b91..69b7264404 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