[exim-cvs] Use File::Path to make directories

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] Use File::Path to make directories
Gitweb: http://git.exim.org/exim-website.git/commitdiff/b24c6fc7166adff432821a2b0452e48d1c6a84d5
Commit:     b24c6fc7166adff432821a2b0452e48d1c6a84d5
Parent:     b33cb55c516a4f29e8cd5d325cec9086d3dde3c2
Author:     Nigel Metheringham <nigel.metheringham@???>
AuthorDate: Sun Apr 24 16:28:35 2011 +0100
Committer:  Nigel Metheringham <nigel.metheringham@???>
CommitDate: Sun Apr 24 16:28:35 2011 +0100


    Use File::Path to make directories
---
 script/gen.pl |   17 ++---------------
 1 files changed, 2 insertions(+), 15 deletions(-)


diff --git a/script/gen.pl b/script/gen.pl
index 685d0eb..9667a7c 100755
--- a/script/gen.pl
+++ b/script/gen.pl
@@ -6,6 +6,7 @@ use warnings;
 use CSS::Minifier::XS 0.07;
 use File::Copy;
 use File::Find;
+use File::Path qw(make_path);
 use File::Slurp;
 use File::Spec;
 use Getopt::Long;
@@ -312,7 +313,7 @@ sub transform {
     my $doc = $stylesheet->transform($xml);


     ## Make the containing directory if it doesn't exist
-    mkdirp( ( $out_path =~ /^(.+)\/.+$/ )[0] );
+    make_path( ( $out_path =~ /^(.+)\/.+$/ )[0], { verbose => 1 } );


     ## Write out the document
     open my $out, '>', $out_path or die "Unable to write $out_path - $!";
@@ -320,20 +321,6 @@ sub transform {
     close $out;
 }


-## "mkdir -p "
-sub mkdirp {
-    my $path = shift;
-
-    my @parts = ();
-    foreach ( split( /\//, $path ) ) {
-        push @parts, $_;
-        my $make = join( '/', @parts );
-        next unless length($make);
-        next if -d $make;
-        mkdir($make) or die "Unable to mkdir $make: $!\n";
-    }
-}
-
 ## error_help
 sub error_help {
     my $msg = shift;