Skip Menu |

This queue is for tickets about the File-Path-Tiny CPAN distribution.

Report information
The Basics
Id: 96842
Status: resolved
Priority: 0/
Queue: File-Path-Tiny

People
Owner: Nobody in particular
Requestors: MITHUN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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;
I added a modified version of your patch to v0.8, thanks! Give it a try and let me know if its works for you or not, if you want to send me a pull request that adds unit tests, that'd be welcome too: https://github.com/drmuey/p5-File-Path-Tiny