| 1 | package URI::file::Win32; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | ▶ | use parent 'URI::file::Base'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use URI::Escape qw(uri_unescape); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 3 | our $VERSION = '5.40'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 13 | ▶ | sub _file_extract_authority { | ||||||||||||||||||
|
Subroutine
_file_extract_authority: called CC=6 SCAR=18.0
| |||||||||||||||||||||
| 13 | 13 | my $class = shift; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 13 | ▶ | return $class->SUPER::_file_extract_authority($_[0]) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 16 | if defined $URI::file::DEFAULT_AUTHORITY; | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 7 | ▶ | return $1 if $_[0] =~ s,^\\\\([^\\]+),,; # UNC | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | 6 | ▶ | return $1 if $_[0] =~ s,^//([^/]+),,; # UNC too? | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 6 | ▶ | if ($_[0] =~ s,^([a-zA-Z]:),,) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 1 | my $auth = $1; | |||||||||||||||||||
| 23 | 1 | ▶ | $auth .= "relative" if $_[0] !~ m,^[\\/],; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 1 | return $auth; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | 5 | return undef; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 13 | ▶ | sub _file_extract_path { | ||||||||||||||||||
|
Subroutine
_file_extract_path: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 30 | 13 | my ($class, $path) = @_; | |||||||||||||||||||
| 31 | 13 | $path =~ s,\\,/,g; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | #$path =~ s,//+,/,g; | ||||||||||||||||||||
| 34 | 13 | $path =~ s,(/\.)+/,/,g; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 13 | ▶ | if (defined $URI::file::DEFAULT_AUTHORITY) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 6 | $path =~ s,^([a-zA-Z]:),/$1,; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 13 | return $path; | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 6 | ▶ | sub _file_is_absolute { | ||||||||||||||||||
|
Subroutine
_file_is_absolute: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 44 | 6 | my ($class, $path) = @_; | |||||||||||||||||||
| 45 | 6 | ▶ | return $path =~ m,^[a-zA-Z]:, || $path =~ m,^[/\\],; | ||||||||||||||||||
|
Condition100%3/3
$path =~ /^[a-zA-Z]:/ || $path =~ m(^[/\\])
MC/DC100%2/2
$path =~ /^[a-zA-Z]:/ || $path =~ m(^[/\\])
$path =~ /^[a-zA-Z]:/
$path =~ m(^[/\\])
Truth table100%3/3
A || B
A= $path =~ /^[a-zA-Z]:/B= $path =~ m(^[/\\])
| |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 26 | ▶ | sub file { | ||||||||||||||||||
|
Subroutine
file: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||
| 49 | 26 | my $class = shift; | |||||||||||||||||||
| 50 | 26 | my $uri = shift; | |||||||||||||||||||
| 51 | 26 | my $auth = $uri->authority; | |||||||||||||||||||
| 52 | 26 | my $rel; # is filename relative to drive specified in authority | |||||||||||||||||||
| 53 | 26 | ▶ | if (defined $auth) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 11 | $auth = uri_unescape($auth); | |||||||||||||||||||
| 55 | 11 | ▶ | if ($auth =~ /^([a-zA-Z])[:|](relative)?/) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 56 | 3 | $auth = uc($1) . ":"; | |||||||||||||||||||
| 57 | 3 | ▶ | $rel++ if $2; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | elsif (lc($auth) eq "localhost") { | ||||||||||||||||||||
| 60 | 2 | $auth = ""; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | elsif (length $auth) { | ||||||||||||||||||||
| 63 | 2 | $auth = "\\\\" . $auth; # UNC | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | else { | ||||||||||||||||||||
| 67 | 15 | $auth = ""; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 26 | my @path = $uri->path_segments; | |||||||||||||||||||
| 71 | 26 | for (@path) { | |||||||||||||||||||
| 72 | 55 | ▶ | return undef if /\0/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | 55 | ▶ | return undef if /\//; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | #return undef if /\\/; # URLs with "\" is not uncommon | ||||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | 26 | ▶ | return undef unless $class->fix_path(@path); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 26 | my $path = join("\\", @path); | |||||||||||||||||||
| 80 | 26 | ▶ | $path =~ s/^\\// if $rel; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | 26 | $path = $auth . $path; | |||||||||||||||||||
| 82 | 26 | $path =~ s,^\\([a-zA-Z])[:|],\u$1:,; | |||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 26 | return $path; | |||||||||||||||||||
| 85 | } | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 24 | ▶ | sub fix_path { 1; } | ||||||||||||||||||
|
Subroutine
fix_path: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 3 | 1; | |||||||||||||||||||