XSRETURN(1);
}
+/* XXX this belongs in doio.c, not here */
PerlIO*
Perl_my_tmpfp(pTHX)
{
PerlIO *f = NULL;
int fd = -1;
-#ifdef PERL_EXTERNAL_GLOB
+#ifdef WIN32
+ fd = win32_tmpfd();
+ if (fd >= 0)
+ f = PerlIO_fdopen(fd, "w+b");
+#else
+# ifdef PERL_EXTERNAL_GLOB
/* File::Temp pulls in Fcntl, which may not be available with
* e.g. miniperl, use mkstemp() or stdio tmpfile() instead. */
-# if defined(WIN32) || !defined(HAS_MKSTEMP)
+# if defined(WIN32) || !defined(HAS_MKSTEMP)
FILE *stdio = PerlSIO_tmpfile();
if (stdio) {
s->stdio = stdio;
}
}
-# else /* !WIN32 && HAS_MKSTEMP */
+# else /* !WIN32 && HAS_MKSTEMP */
SV *sv = newSVpv("/tmp/PerlIO_XXXXXX", 0);
if (sv) {
}
}
}
-# endif /* WIN32 || !HAS_MKSTEMP */
-#else
+# endif /* !HAS_MKSTEMP */
+# else
/* We have internal glob, which probably also means that we
* can also use File::Temp (which uses Fcntl) with impunity. */
GV *gv = gv_fetchpv("File::Temp::tempfile", FALSE, SVt_PVCV);
FREETMPS;
LEAVE;
}
+# endif
#endif
return f;
}
-
return;
}
-DllExport FILE*
-win32_tmpfile(void)
+DllExport int
+win32_tmpfd(void)
{
dTHX;
char prefix[MAX_PATH+1];
#endif
DEBUG_p(PerlIO_printf(Perl_debug_log,
"Created tmpfile=%s\n",filename));
- return fdopen(fd, "w+b");
+ return fd;
}
}
}
}
+ return -1;
+}
+
+DllExport FILE*
+win32_tmpfile(void)
+{
+ int fd = win32_tmpfd();
+ if (fd >= 0)
+ return win32_fdopen(fd, "w+b");
return NULL;
}
DllExport int win32_fgetpos(FILE *pf,fpos_t *p);
DllExport int win32_fsetpos(FILE *pf,const fpos_t *p);
DllExport void win32_rewind(FILE *pf);
+DllExport int win32_tmpfd(void);
DllExport FILE* win32_tmpfile(void);
DllExport void win32_abort(void);
DllExport int win32_fstat(int fd,Stat_t *sbufptr);