diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-10-20 14:25:37 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-10-20 14:25:37 +0000 |
commit | 06c7082d6226d352105bade1a7e185ff0a49e896 (patch) | |
tree | 39eedf1073fc64f1b55d2314cbb1ba0b0ab85691 /doio.c | |
parent | ed1c0269a31901e89fe8c0090d5c6cb7881eeb2f (diff) | |
download | perl-06c7082d6226d352105bade1a7e185ff0a49e896.tar.gz |
Extract doio.c's open(2) mode to string conversion as PerlIO_intmod2str()
Use for non-PERLIO fdupopen().
p4raw-id: //depot/perlio@12532
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 42 |
1 files changed, 2 insertions, 40 deletions
@@ -158,45 +158,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, rawmode |= O_LARGEFILE; /* Transparently largefiley. */ #endif -#ifndef O_ACCMODE -#define O_ACCMODE 3 /* Assume traditional implementation */ -#endif - - switch (result = rawmode & O_ACCMODE) { - case O_RDONLY: - IoTYPE(io) = IoTYPE_RDONLY; - break; - case O_WRONLY: - IoTYPE(io) = IoTYPE_WRONLY; - break; - case O_RDWR: - default: - IoTYPE(io) = IoTYPE_RDWR; - break; - } - writing = (result != O_RDONLY); - - if (result == O_RDONLY) { - mode[ix++] = 'r'; - } -#ifdef O_APPEND - else if (rawmode & O_APPEND) { - mode[ix++] = 'a'; - if (result != O_WRONLY) - mode[ix++] = '+'; - } -#endif - else { - if (result == O_WRONLY) - mode[ix++] = 'w'; - else { - mode[ix++] = 'r'; - mode[ix++] = '+'; - } - } - if (rawmode & O_BINARY) - mode[ix++] = 'b'; - mode[ix] = '\0'; + IoTYPE(io) = PerlIO_intmode2str(rawmode, &mode[ix], &writing); namesv = sv_2mortal(newSVpvn(name,strlen(name))); num_svs = 1; @@ -1693,7 +1655,7 @@ nothing in the core. if ( accessed == &PL_sv_undef && modified == &PL_sv_undef ) utbufp = NULL; - + Zero(&utbuf, sizeof utbuf, char); #ifdef BIG_TIME utbuf.actime = (Time_t)SvNVx(accessed); /* time accessed */ |