From: David Landgren Date: Tue, 13 Nov 2007 14:44:22 +0000 (+0100) Subject: Re: [PATCH] File-Path-2.04 (this time with patch) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=351a5cfe859bc8fbf20a6fe8702a7b8bb994067c;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] File-Path-2.04 (this time with patch) Message-ID: <4739AA36.7000809@landgren.net> p4raw-id: //depot/perl@32305 --- diff --git a/lib/File/Path.pm b/lib/File/Path.pm index 031430a..19b5750 100644 --- a/lib/File/Path.pm +++ b/lib/File/Path.pm @@ -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 + +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. + +=item * + L When removing directory trees, if you want to examine each file to diff --git a/lib/File/Path.t b/lib/File/Path.t index 646d5cb..f1b5928 100755 --- a/lib/File/Path.t +++ b/lib/File/Path.t @@ -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 ''");