diff options
author | Tony Cook <tony@develop-help.com> | 2019-07-15 11:53:23 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2019-07-16 15:30:06 +1000 |
commit | 74b421cc877e412c4eda06757396a1e19fc756ba (patch) | |
tree | d51488c4218e0f6407eeac7a0d1dc586884c458d /perlio.c | |
parent | 0424723402ef153af8ee44222315d9b6a818d1ba (diff) | |
download | perl-74b421cc877e412c4eda06757396a1e19fc756ba.tar.gz |
(perl #134221) support O_APPEND for open ..., undef on VMS
VMS doesn't allow you to delete an open file like POSIXish systems
do, but you can mark a file to be deleted once it's closed, but
only when you open it.
Since VMS doesn't (yet) have mkostemp() we can add our own flag to
our mkostemp() emulation to pass the necessary magic to open() call
to delete the file on close.
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -5062,7 +5062,7 @@ PerlIO_tmpfile_flags(int imode) const int fd = win32_tmpfd_mode(imode); if (fd >= 0) f = PerlIO_fdopen(fd, "w+b"); -#elif ! defined(VMS) && ! defined(OS2) +#elif ! defined(OS2) int fd = -1; char tempname[] = "/tmp/PerlIO_XXXXXX"; const char * const tmpdir = TAINTING_get ? NULL : PerlEnv_getenv("TMPDIR"); @@ -5073,19 +5073,19 @@ PerlIO_tmpfile_flags(int imode) /* if TMPDIR is set and not empty, we try that first */ sv = newSVpv(tmpdir, 0); sv_catpv(sv, tempname + 4); - fd = Perl_my_mkostemp_cloexec(SvPVX(sv), imode); + fd = Perl_my_mkostemp_cloexec(SvPVX(sv), imode | O_VMS_DELETEONCLOSE); } if (fd < 0) { SvREFCNT_dec(sv); sv = NULL; /* else we try /tmp */ - fd = Perl_my_mkostemp_cloexec(tempname, imode); + fd = Perl_my_mkostemp_cloexec(tempname, imode | O_VMS_DELETEONCLOSE); } if (fd < 0) { /* Try cwd */ sv = newSVpvs("."); sv_catpv(sv, tempname + 4); - fd = Perl_my_mkostemp_cloexec(SvPVX(sv), imode); + fd = Perl_my_mkostemp_cloexec(SvPVX(sv), imode | O_VMS_DELETEONCLOSE); } umask(old_umask); if (fd >= 0) { @@ -5096,7 +5096,9 @@ PerlIO_tmpfile_flags(int imode) f = PerlIO_fdopen(fd, mode); if (f) PerlIOBase(f)->flags |= PERLIO_F_TEMP; +# ifndef VMS PerlLIO_unlink(sv ? SvPVX_const(sv) : tempname); +# endif } SvREFCNT_dec(sv); #else /* !HAS_MKSTEMP, fallback to stdio tmpfile(). */ |