This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid failure if directories already read by rmtree() are
authorGurusamy Sarathy <gsar@cpan.org>
Wed, 26 Jan 2000 00:33:53 +0000 (00:33 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Wed, 26 Jan 2000 00:33:53 +0000 (00:33 +0000)
deleted by another process

p4raw-id: //depot/perl@4894

lib/File/Path.pm

index bac48a1..59b72ba 100644 (file)
@@ -94,14 +94,12 @@ Charles Bailey <F<bailey@newman.upenn.edu>>
 use 5.005_64;
 use Carp;
 use File::Basename ();
-use DirHandle ();
 use Exporter ();
 use strict;
 
-our($VERSION, @ISA, @EXPORT);
-$VERSION = "1.0402";
-@ISA = qw( Exporter );
-@EXPORT = qw( mkpath rmtree );
+our $VERSION = "1.0403";
+our @ISA = qw( Exporter );
+our @EXPORT = qw( mkpath rmtree );
 
 my $Is_VMS = $^O eq 'VMS';
 
@@ -171,10 +169,14 @@ sub rmtree {
              or carp "Can't make directory $root read+writeable: $!"
                unless $safe;
 
-           my $d = DirHandle->new($root)
-             or carp "Can't read $root: $!";
-           @files = $d->read;
-           $d->close;
+           if (opendir my $d, $root) {
+               @files = readdir $d;
+               closedir $d;
+           }
+           else {
+               carp "Can't read $root: $!";
+               @files = ();
+           }
 
            # Deleting large numbers of files from VMS Files-11 filesystems
            # is faster if done in reverse ASCIIbetical order