diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-06-03 08:04:39 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-06-03 08:04:39 +0000 |
commit | 245468ebf9e9a3ea7e3600e1d4513bdc24459c6b (patch) | |
tree | a401369700632acba7b1a5611531bb2a5a9accec /perlio.c | |
parent | cab02963b8a3a0067a2c0c2a6edd2ef2af19842f (diff) | |
download | perl-245468ebf9e9a3ea7e3600e1d4513bdc24459c6b.tar.gz |
Retract #19667, #19660, #19659, #19658, #19657, #19656,
#19655, #19418; File::Temp no more used internally.
Some parts of these will be salvaged later.
p4raw-id: //depot/perl@19670
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 44 |
1 files changed, 37 insertions, 7 deletions
@@ -4814,13 +4814,35 @@ PerlIO_stdoutf(const char *fmt, ...) PerlIO * PerlIO_tmpfile(void) { - dTHX; - PerlIO *f = Perl_my_tmpfp(aTHX); - - if (f) - PerlIOBase(f)->flags |= PERLIO_F_TEMP; - - return f; + /* + * I have no idea how portable mkstemp() is ... + */ +#if defined(WIN32) || !defined(HAVE_MKSTEMP) + dTHX; + PerlIO *f = NULL; + FILE *stdio = PerlSIO_tmpfile(); + if (stdio) { + if ((f = PerlIO_push(aTHX_(PerlIO_allocate(aTHX)), &PerlIO_stdio, "w+", Nullsv))) { + PerlIOStdio *s = PerlIOSelf(f, PerlIOStdio); + s->stdio = stdio; + } + } + return f; +#else + dTHX; + SV *sv = newSVpv("/tmp/PerlIO_XXXXXX", 0); + int fd = mkstemp(SvPVX(sv)); + PerlIO *f = NULL; + if (fd >= 0) { + f = PerlIO_fdopen(fd, "w+"); + if (f) { + PerlIOBase(f)->flags |= PERLIO_F_TEMP; + } + PerlLIO_unlink(SvPVX(sv)); + SvREFCNT_dec(sv); + } + return f; +#endif } #undef HAS_FSETPOS @@ -4949,3 +4971,11 @@ PerlIO_sprintf(char *s, int n, const char *fmt, ...) return result; } #endif + + + + + + + + |