X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FFile%2FPath.pm;h=0eb6128afe6a3cdb47d2279ff226f7c833a5c783;hb=ffb9ee5f5f9d80d28ce950a2ff357650c8f1cc03;hp=3859f248eb0543416aa6b2cf1908d7bcb8945029;hpb=fa6a1c441b7e2c8c5e7ee1e3836a41fc8a364e89;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/File/Path.pm b/lib/File/Path.pm index 3859f24..0eb6128 100644 --- a/lib/File/Path.pm +++ b/lib/File/Path.pm @@ -97,11 +97,12 @@ use File::Basename (); use Exporter (); use strict; -our $VERSION = "1.0403"; +our $VERSION = "1.0404"; our @ISA = qw( Exporter ); our @EXPORT = qw( mkpath rmtree ); my $Is_VMS = $^O eq 'VMS'; +my $Is_MacOS = $^O eq 'MacOS'; # These OSes complain if you want to remove a file that you have no # write permission to: @@ -113,7 +114,7 @@ sub mkpath { # $paths -- either a path string or ref to list of paths # $verbose -- optional print "mkdir $path" for each directory created # $mode -- optional permissions, defaults to 0777 - local($")="/"; + local($")=$Is_MacOS ? ":" : "/"; $mode = 0777 unless defined($mode); $paths = [$paths] unless ref $paths; my(@created,$path); @@ -160,7 +161,12 @@ sub rmtree { my($root); foreach $root (@{$roots}) { - $root =~ s#/\z##; + if ($Is_MacOS) { + $root = ":$root" if $root !~ /:/; + $root =~ s#([^:])\z#$1:#; + } else { + $root =~ s#/\z##; + } (undef, undef, my $rp) = lstat $root or next; $rp &= 07777; # don't forget setuid, setgid, sticky bits if ( -d _ ) { @@ -185,7 +191,11 @@ sub rmtree { # is faster if done in reverse ASCIIbetical order @files = reverse @files if $Is_VMS; ($root = VMS::Filespec::unixify($root)) =~ s#\.dir\z## if $Is_VMS; - @files = map("$root/$_", grep $_!~/^\.{1,2}\z/s,@files); + if ($Is_MacOS) { + @files = map("$root$_", @files); + } else { + @files = map("$root/$_", grep $_!~/^\.{1,2}\z/s,@files); + } $count += rmtree(\@files,$verbose,$safe); if ($safe && ($Is_VMS ? !&VMS::Filespec::candelete($root) : !-w $root)) {