X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FFile%2FPath.pm;h=46af24fdb2027caf70084a79e989ba8dae84bd23;hb=35c0985d87e203a100f5c5fc6518bee6a2e2fd9d;hp=3560a970a26c2b32b6638f07a3a59e800888cb1f;hpb=3b825e419da1c361eab06a1e6d287276c0aef241;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/File/Path.pm b/lib/File/Path.pm index 3560a97..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: @@ -98,7 +107,7 @@ 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 {