X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FFile%2FPath.pm;h=46af24fdb2027caf70084a79e989ba8dae84bd23;hb=35c0985d87e203a100f5c5fc6518bee6a2e2fd9d;hp=7d56d48f28382e64f956bbe12a43f394cb5fc8c5;hpb=88d01e8dd0be693cf54a3bafc9974fa70eda2ddd;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/File/Path.pm b/lib/File/Path.pm index 7d56d48..46af24f 100644 --- a/lib/File/Path.pm +++ b/lib/File/Path.pm @@ -40,6 +40,15 @@ the numeric mode to use when creating the directories It returns a list of all directories (including intermediates, determined using the Unix '/' separator) created. +If a system error prevents a directory from being created, then the +C function throws a fatal error with C. This error +can be trapped with an C block: + + eval { mkpath($dir) }; + if ($@) { + print "Couldn't create $dir: $@"; + } + Similarly, the C function provides a convenient way to delete a subtree from the directory structure, much like the Unix command C. C takes three arguments: @@ -91,14 +100,14 @@ Charles Bailey > =cut -use 5.6.0; +use 5.006; use Carp; use File::Basename (); use Exporter (); use strict; use warnings; -our $VERSION = "1.0405"; +our $VERSION = "1.05"; our @ISA = qw( Exporter ); our @EXPORT = qw( mkpath rmtree ); @@ -180,7 +189,13 @@ sub rmtree { unless $safe; if (opendir my $d, $root) { - @files = readdir $d; + no strict 'refs'; + if (!defined ${"\cTAINT"} or ${"\cTAINT"}) { + # Blindly untaint dir names + @files = map { /^(.*)$/s ; $1 } readdir $d; + } else { + @files = readdir $d; + } closedir $d; } else {