Subject: | Cannot use `mk` to create UNC paths on windows |
Trying `File::Path::Tiny::mk('\\\\foo\\bar\\baz')` does not work.
I've attached a patch.
-Mithun
Subject: | Tiny.pm.patch |
--- Tiny.pm 2014-06-30 14:15:38.556179300 -0500
+++ lib/File/Path/Tiny.pm 2014-06-30 14:16:40.317179300 -0500
@@ -12,17 +12,16 @@
$mask ||= '0777'; # Perl::Critic == Integer with leading zeros at ...
$mask = oct($mask) if substr( $mask, 0, 1 ) eq '0';
require File::Spec;
- my ( $progressive, @parts ) = File::Spec->splitdir($path);
- if ( !defined $progressive || $progressive eq '' ) {
- $progressive = File::Spec->catdir( $progressive, shift(@parts) );
- }
- if ( !-d $progressive ) {
- mkdir( $progressive, $mask ) or return;
- }
- for my $part (@parts) {
- $progressive = File::Spec->catdir( $progressive, $part );
- if ( !-d $progressive ) {
- mkdir( $progressive, $mask ) or return;
+ my ( $vol, $directories ) = File::Spec->splitpath( $path, 1 );
+ my @dirs = File::Spec->splitdir($directories);
+ my @list;
+ while ( my ($_dir) = shift @dirs ) {
+ last if not defined $_dir;
+ push @list, $_dir;
+ next if ( $_dir eq '' );
+ my $_mk = File::Spec->catpath( $vol, File::Spec->catdir(@list) );
+ if ( not -d $_mk ) {
+ mkdir( $_mk, $mask ) or return;
}
}
return 1 if -d $path;