File Coverage

lib/Perlmazing/Perlmazing/splitpath.pm
Criterion Covered Total %
statement 13 13 100.0
branch 6 8 75.0
condition 4 6 66.6
subroutine 2 2 100.0
pod 0 1 0.0
total 25 30 83.3


line stmt bran cond sub pod time code
1 1     1   9 use File::Spec ();
  1         1  
  1         240  
2             require File::Spec::Win32;
3              
4             sub main {
5 8     8 0 57 my $path = shift;
6 8 50       20 return unless defined $path;
7             # A little hack is needed for UNC paths under File::Spec
8 8         19 local $1;
9 8 100       29 my $unc_name = $path =~ /^\\\\(\w+)/ ? $1 : undef;
10 8 100       17 if (defined $unc_name) {
11             # Let's have it treat it like a regular Win32 path
12 5         40 $path =~ s/^\\\\$unc_name/C:/;
13             }
14 8         25 my @items = File::Spec::Win32->splitpath($path);
15 8 50 66     297 if (defined $unc_name and @items and length $items[0]) {
      66        
16 5         11 $items[0] = "\\\\$unc_name";
17             }
18 8         40 @items;
19             }
20              
21             1;