summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@perl.com>1997-04-17 05:47:04 +1200
committerChip Salzenberg <chip@atlantic.net>1997-04-25 00:00:00 +1200
commit7025f710301089a3f0e734f3192916a373b2e2e9 (patch)
treece2cd1dc0c3d365dbfda34e127dec7c97d8725bc
parent0caed002bbf7ef75ea0a818a799f3c6a3d30f4e5 (diff)
downloadperl-7025f710301089a3f0e734f3192916a373b2e2e9.tar.gz
Handle symlinks, high permission bits in File::Path
-rw-r--r--lib/File/Path.pm11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/File/Path.pm b/lib/File/Path.pm
index 419bd03adf..fe56ae5365 100644
--- a/lib/File/Path.pm
+++ b/lib/File/Path.pm
@@ -92,7 +92,7 @@ Charles Bailey <F<bailey@genetics.upenn.edu>>
=head1 REVISION
-Current $VERSION is 1.03.
+Current $VERSION is 1.04.
=cut
@@ -103,7 +103,7 @@ use Exporter ();
use strict;
use vars qw( $VERSION @ISA @EXPORT );
-$VERSION = "1.03";
+$VERSION = "1.04";
@ISA = qw( Exporter );
@EXPORT = qw( mkpath rmtree );
@@ -147,13 +147,13 @@ sub rmtree {
my($root);
foreach $root (@{$roots}) {
$root =~ s#/$##;
- next unless -e $root;
- if (not -l $root and -d _) {
+ (undef, undef, my $rp) = lstat $root or next;
+ $rp &= 07777; # don't forget setuid, setgid, sticky bits
+ if ( -d _ ) {
# notabene: 0777 is for making readable in the first place,
# it's also intended to change it to writable in case we have
# to recurse in which case we are better than rm -rf for
# subtrees with strange permissions
- my $rp = (stat(_))[2] & 0777; #Is this portable???
chmod(0777, ($Is_VMS ? VMS::Filespec::fileify($root) : $root))
or carp "Can't make directory $root read+writeable: $!"
unless $safe;
@@ -194,7 +194,6 @@ sub rmtree {
print "skipped $root\n" if $verbose;
next;
}
- my $rp = (stat(_))[2] & 0777; #Is this portable???
chmod 0666, $root
or carp "Can't make file $root writeable: $!"
if $force_writeable;