diff options
author | David Landgren <david@landgren.net> | 2007-11-13 15:44:22 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-11-13 14:19:46 +0000 |
commit | 351a5cfe859bc8fbf20a6fe8702a7b8bb994067c (patch) | |
tree | 8ae142fa7c3f71684655f31f854f3de0f798ac6b /lib/File | |
parent | 1f80753b60b5b911f4c06c6d6b20d889c978eaed (diff) | |
download | perl-351a5cfe859bc8fbf20a6fe8702a7b8bb994067c.tar.gz |
Re: [PATCH] File-Path-2.04 (this time with patch)
Message-ID: <4739AA36.7000809@landgren.net>
p4raw-id: //depot/perl@32305
Diffstat (limited to 'lib/File')
-rw-r--r-- | lib/File/Path.pm | 19 | ||||
-rwxr-xr-x | lib/File/Path.t | 21 |
2 files changed, 33 insertions, 7 deletions
diff --git a/lib/File/Path.pm b/lib/File/Path.pm index 031430abb9..19b5750b45 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<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 diff --git a/lib/File/Path.t b/lib/File/Path.t index 646d5cb47f..f1b5928656 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 ''"); |