diff options
author | Steve Peters <steve@fisharerojo.org> | 2006-07-03 18:09:01 +0000 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2006-07-03 18:09:01 +0000 |
commit | 5228a96c60a47c008c307f4fa3bf942383d38423 (patch) | |
tree | 70ae56d50266f791be5436a6f593a84a7cf33c94 /pp_sys.c | |
parent | 88e01c9dba7e9c1403ea12dc83a20252782bb76f (diff) | |
download | perl-5228a96c60a47c008c307f4fa3bf942383d38423.tar.gz |
Allow stat() and -X file tests work on dirhandles.
p4raw-id: //depot/perl@28473
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -2790,9 +2790,26 @@ PP(pp_stat) PL_laststype = OP_STAT; PL_statgv = gv; sv_setpvn(PL_statname, "", 0); - PL_laststatval = (GvIO(gv) && IoIFP(GvIOp(gv)) - ? PerlLIO_fstat(PerlIO_fileno(IoIFP(GvIOn(gv))), &PL_statcache) : -1); - } + if(gv) { + IO* const io = GvIO(gv); + if (io) { + if (IoIFP(io)) { + PL_laststatval = + PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache); + } else if (IoDIRP(io)) { +#ifdef HAS_DIRFD + PL_laststatval = + PerlLIO_fstat(dirfd(IoDIRP(io)), &PL_statcache); +#else + DIE(aTHX_ PL_no_func, "dirfd"); +#endif + } else { + PL_laststatval = -1; + } + } + } + } + if (PL_laststatval < 0) { if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) report_evil_fh(gv, GvIO(gv), PL_op->op_type); |