summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorGisle Aas <gisle@aas.no>2005-07-14 19:32:50 -0700
committerH.Merijn Brand <h.m.brand@xs4all.nl>2005-07-16 08:07:44 +0000
commitc4aca7d03737ddcac23de1ad6d597e98be679214 (patch)
tree0a3a2c3042bba6da8246cf336e1c4d10f6aa61d1 /doio.c
parentaec46f14fac1bc74bf8ad4054a6f9674b324f8d2 (diff)
downloadperl-c4aca7d03737ddcac23de1ad6d597e98be679214.tar.gz
Re: fchmod, fchown, fchdir
Message-ID: <lrwtnse7nh.fsf@caliper.activestate.com> + Schwern's ok -> like changes p4raw-id: //depot/perl@25157
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c62
1 files changed, 54 insertions, 8 deletions
diff --git a/doio.c b/doio.c
index 4d7d19b955..61a5371958 100644
--- a/doio.c
+++ b/doio.c
@@ -1677,10 +1677,33 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
- const char *name = SvPV_nolen_const(*mark);
- APPLY_TAINT_PROPER();
- if (PerlLIO_chmod(name, val))
- tot--;
+ GV* gv;
+ if (SvTYPE(*mark) == SVt_PVGV) {
+ gv = (GV*)*mark;
+ do_fchmod:
+ if (GvIO(gv) && IoIFP(GvIOp(gv))) {
+#ifdef HAS_FCHMOD
+ APPLY_TAINT_PROPER();
+ if (fchmod(PerlIO_fileno(IoIFP(GvIOn(gv))), val))
+ tot--;
+#else
+ DIE(aTHX_ PL_no_func, "fchmod");
+#endif
+ }
+ else {
+ tot--;
+ }
+ }
+ else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) {
+ gv = (GV*)SvRV(*mark);
+ goto do_fchmod;
+ }
+ else {
+ const char *name = SvPV_nolen_const(*mark);
+ APPLY_TAINT_PROPER();
+ if (PerlLIO_chmod(name, val))
+ tot--;
+ }
}
}
break;
@@ -1695,10 +1718,33 @@ Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
- const char *name = SvPV_nolen_const(*mark);
- APPLY_TAINT_PROPER();
- if (PerlLIO_chown(name, val, val2))
- tot--;
+ GV* gv;
+ if (SvTYPE(*mark) == SVt_PVGV) {
+ gv = (GV*)*mark;
+ do_fchown:
+ if (GvIO(gv) && IoIFP(GvIOp(gv))) {
+#ifdef HAS_FCHOWN
+ APPLY_TAINT_PROPER();
+ if (fchown(PerlIO_fileno(IoIFP(GvIOn(gv))), val, val2))
+ tot--;
+#else
+ DIE(aTHX_ PL_no_func, "fchown");
+#endif
+ }
+ else {
+ tot--;
+ }
+ }
+ else if (SvROK(*mark) && SvTYPE(SvRV(*mark)) == SVt_PVGV) {
+ gv = (GV*)SvRV(*mark);
+ goto do_fchown;
+ }
+ else {
+ const char *name = SvPV_nolen_const(*mark);
+ APPLY_TAINT_PROPER();
+ if (PerlLIO_chown(name, val, val2))
+ tot--;
+ }
}
}
break;