use Exporter ();
use vars qw($VERSION @ISA @EXPORT);
-$VERSION = '2.02_01';
+$VERSION = '2.04';
@ISA = qw(Exporter);
@EXPORT = qw(mkpath rmtree);
# 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;
}
else {
# not a directory
-
$root = VMS::Filespec::vmsify("./$root")
if $Is_VMS
&& !File::Spec->file_name_is_absolute($root)
=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
=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
use strict;
-use Test::More tests => 98;
+use Test::More tests => 99;
BEGIN {
use_ok('File::Path');
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 ''");