This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] File-Path-2.04 (this time with patch)
authorDavid Landgren <david@landgren.net>
Tue, 13 Nov 2007 14:44:22 +0000 (15:44 +0100)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 13 Nov 2007 14:19:46 +0000 (14:19 +0000)
Message-ID: <4739AA36.7000809@landgren.net>

p4raw-id: //depot/perl@32305

lib/File/Path.pm
lib/File/Path.t

index 031430a..19b5750 100644 (file)
@@ -17,7 +17,7 @@ BEGIN {
 
 use Exporter ();
 use vars qw($VERSION @ISA @EXPORT);
-$VERSION = '2.02_01';
+$VERSION = '2.04';
 @ISA     = qw(Exporter);
 @EXPORT  = qw(mkpath rmtree);
 
@@ -26,8 +26,7 @@ my $Is_MacOS = $^O eq 'MacOS';
 
 # These OSes complain if you want to remove a file that you have no
 # write permission to:
-my $Force_Writeable = ($^O eq 'os2' || $^O eq 'dos' || $^O eq 'MSWin32' ||
-                       $^O eq 'amigaos' || $^O eq 'MacOS' || $^O eq 'epoc');
+my $Force_Writeable = grep {$^O eq $_} qw(amigaos dos epoc MSWin32 MacOS os2);
 
 sub _carp {
     require Carp;
@@ -338,7 +337,6 @@ sub _rmtree {
         }
         else {
             # not a directory
-
             $root = VMS::Filespec::vmsify("./$root")
                 if $Is_VMS 
                    && !File::Spec->file_name_is_absolute($root)
@@ -388,8 +386,8 @@ File::Path - Create or remove directory trees
 
 =head1 VERSION
 
-This document describes version 2.02 of File::Path, released
-2007-10-24.
+This document describes version 2.04 of File::Path, released
+2007-11-13.
 
 =head1 SYNOPSIS
 
@@ -850,6 +848,15 @@ setting. (Permissions given in octal).
 
 =item *
 
+L<File::Remove>
+
+Allows files and directories to be moved to the Trashcan/Recycle
+Bin (where they may later be restored if necessary) if the operating
+system supports such functionality. This feature may one day be
+made available directly in C<File::Path>.
+
+=item *
+
 L<File::Find::Rule>
 
 When removing directory trees, if you want to examine each file to
index 646d5cb..f1b5928 100755 (executable)
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 98;
+use Test::More tests => 99;
 
 BEGIN {
     use_ok('File::Path');
@@ -54,6 +54,25 @@ is(scalar(@created), 7, "created list of directories");
 is(scalar(@created), 0, "skipped making existing directory")
     or diag("unexpectedly recreated @created");
 
+# create a file
+my $file_name = catfile( $tmp_base, 'a', 'delete.me' );
+my $file_count = 0;
+if (open OUT, "> $file_name") {
+    print OUT "this file may be deleted\n";
+    close OUT;
+    ++$file_count;
+}
+else {
+    diag( "Failed to create file $file_name: $!" );
+}
+
+SKIP: {
+    skip "cannot remove a file we failed to create", 1
+        unless $file_count == 1;
+    my $count = rmtree($file_name);
+    is($count, 1, "rmtree'ed a file");
+}
+
 @created = mkpath('');
 is(scalar(@created), 0, "Can't create a directory named ''");