From: Ben Morrow Date: Tue, 20 Jan 2009 08:34:03 +0000 (+0000) Subject: Warnings for File::stat deficiencies. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7c4737f313e6085f029224b28d6e76d03b072fa;p=p5sagit%2Fp5-mst-13.2.git Warnings for File::stat deficiencies. --- diff --git a/lib/File/stat.pm b/lib/File/stat.pm index 768ab02..55d6c8a 100644 --- a/lib/File/stat.pm +++ b/lib/File/stat.pm @@ -3,8 +3,11 @@ use 5.006; use strict; use warnings; +use warnings::register; use Carp; +BEGIN { *warnif = \&warnings::warnif } + our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); our $VERSION = '1.01'; @@ -138,12 +141,25 @@ my %op = ( A => sub { ($^T - $_[0][8] ) / 86400 }, ); +use constant HINT_FILETEST_ACCESS => 0x00400000; + # we need fallback=>1 or stringifying breaks use overload fallback => 1, -X => sub { my ($s, $op) = @_; + if (index "rwxRWX", $op) { + (caller 0)[8] & HINT_FILETEST_ACCESS + and warnif("File::stat ignores use filetest 'access'"); + + $^O eq "VMS" and warnif("File::stat ignores VMS ACLs"); + + # It would be nice to have a warning about using -l on a + # non-lstat, but that would require an extra member in the + # object. + } + if ($op{$op}) { return $op{$op}->($_[0]); }