line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::file::Mac; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
96
|
|
4
|
3
|
|
|
3
|
|
30
|
use warnings; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
87
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
16
|
use parent 'URI::file::Base'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
16
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
247
|
use URI::Escape qw(uri_unescape); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
2970
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '5.19'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _file_extract_path |
13
|
|
|
|
|
|
|
{ |
14
|
12
|
|
|
12
|
|
22
|
my $class = shift; |
15
|
12
|
|
|
|
|
17
|
my $path = shift; |
16
|
|
|
|
|
|
|
|
17
|
12
|
|
|
|
|
18
|
my @pre; |
18
|
12
|
100
|
|
|
|
60
|
if ($path =~ s/^(:+)//) { |
19
|
10
|
100
|
|
|
|
32
|
if (length($1) == 1) { |
20
|
6
|
100
|
|
|
|
18
|
@pre = (".") unless length($path); |
21
|
|
|
|
|
|
|
} else { |
22
|
4
|
|
|
|
|
13
|
@pre = ("..") x (length($1) - 1); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} else { #absolute |
25
|
2
|
|
|
|
|
4
|
$pre[0] = ""; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
12
|
|
|
|
|
33
|
my $isdir = ($path =~ s/:$//); |
29
|
12
|
|
|
|
|
22
|
$path =~ s,([%/;]), URI::Escape::escape_char($1),eg; |
|
0
|
|
|
|
|
0
|
|
30
|
|
|
|
|
|
|
|
31
|
12
|
|
|
|
|
30
|
my @path = split(/:/, $path, -1); |
32
|
12
|
|
|
|
|
23
|
for (@path) { |
33
|
12
|
100
|
100
|
|
|
60
|
if ($_ eq "." || $_ eq "..") { |
34
|
4
|
|
|
|
|
10
|
$_ = "%2E" x length($_); |
35
|
|
|
|
|
|
|
} |
36
|
12
|
50
|
|
|
|
27
|
$_ = ".." unless length($_); |
37
|
|
|
|
|
|
|
} |
38
|
12
|
50
|
|
|
|
24
|
push (@path,"") if $isdir; |
39
|
12
|
|
|
|
|
48
|
(join("/", @pre, @path), 1); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub file |
44
|
|
|
|
|
|
|
{ |
45
|
27
|
|
|
27
|
0
|
45
|
my $class = shift; |
46
|
27
|
|
|
|
|
35
|
my $uri = shift; |
47
|
27
|
|
|
|
|
38
|
my @path; |
48
|
|
|
|
|
|
|
|
49
|
27
|
|
|
|
|
68
|
my $auth = $uri->authority; |
50
|
27
|
100
|
|
|
|
75
|
if (defined $auth) { |
51
|
11
|
100
|
100
|
|
|
57
|
if (lc($auth) ne "localhost" && $auth ne "") { |
52
|
5
|
|
|
|
|
15
|
my $u_auth = uri_unescape($auth); |
53
|
5
|
50
|
|
|
|
30
|
if (!$class->_file_is_localhost($u_auth)) { |
54
|
|
|
|
|
|
|
# some other host (use it as volume name) |
55
|
5
|
|
|
|
|
76
|
@path = ("", $auth); |
56
|
|
|
|
|
|
|
# XXX or just return to make it illegal; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
27
|
|
|
|
|
60
|
my @ps = split("/", $uri->path, -1); |
61
|
27
|
100
|
|
|
|
71
|
shift @ps if @path; |
62
|
27
|
|
|
|
|
63
|
push(@path, @ps); |
63
|
|
|
|
|
|
|
|
64
|
27
|
|
|
|
|
41
|
my $pre = ""; |
65
|
27
|
50
|
|
|
|
89
|
if (!@path) { |
|
|
100
|
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
return; # empty path; XXX return ":" instead? |
67
|
|
|
|
|
|
|
} elsif ($path[0] eq "") { |
68
|
|
|
|
|
|
|
# absolute |
69
|
16
|
|
|
|
|
23
|
shift(@path); |
70
|
16
|
100
|
|
|
|
40
|
if (@path == 1) { |
71
|
2
|
50
|
|
|
|
12
|
return if $path[0] eq ""; # not root directory |
72
|
0
|
|
|
|
|
0
|
push(@path, ""); # volume only, effectively append ":" |
73
|
|
|
|
|
|
|
} |
74
|
14
|
|
|
|
|
37
|
@ps = @path; |
75
|
14
|
|
|
|
|
28
|
@path = (); |
76
|
14
|
|
|
|
|
20
|
my $part; |
77
|
14
|
|
|
|
|
29
|
for (@ps) { #fix up "." and "..", including interior, in relatives |
78
|
28
|
50
|
|
|
|
55
|
next if $_ eq "."; |
79
|
28
|
50
|
|
|
|
53
|
$part = $_ eq ".." ? "" : $_; |
80
|
28
|
|
|
|
|
48
|
push(@path,$part); |
81
|
|
|
|
|
|
|
} |
82
|
14
|
50
|
|
|
|
43
|
if ($ps[-1] eq "..") { #if this happens, we need another : |
83
|
0
|
|
|
|
|
0
|
push(@path,""); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} else { |
87
|
11
|
|
|
|
|
19
|
$pre = ":"; |
88
|
11
|
|
|
|
|
29
|
@ps = @path; |
89
|
11
|
|
|
|
|
21
|
@path = (); |
90
|
11
|
|
|
|
|
15
|
my $part; |
91
|
11
|
|
|
|
|
20
|
for (@ps) { #fix up "." and "..", including interior, in relatives |
92
|
17
|
100
|
|
|
|
33
|
next if $_ eq "."; |
93
|
15
|
100
|
|
|
|
32
|
$part = $_ eq ".." ? "" : $_; |
94
|
15
|
|
|
|
|
28
|
push(@path,$part); |
95
|
|
|
|
|
|
|
} |
96
|
11
|
100
|
|
|
|
28
|
if ($ps[-1] eq "..") { #if this happens, we need another : |
97
|
2
|
|
|
|
|
5
|
push(@path,""); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
25
|
50
|
66
|
|
|
91
|
return unless $pre || @path; |
102
|
25
|
|
|
|
|
44
|
for (@path) { |
103
|
40
|
|
|
|
|
68
|
s/;.*//; # get rid of parameters |
104
|
|
|
|
|
|
|
#return unless length; # XXX |
105
|
40
|
|
|
|
|
82
|
$_ = uri_unescape($_); |
106
|
40
|
50
|
|
|
|
150
|
return if /\0/; |
107
|
40
|
100
|
|
|
|
113
|
return if /:/; # Should we? |
108
|
|
|
|
|
|
|
} |
109
|
20
|
|
|
|
|
114
|
$pre . join(":", @path); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub dir |
113
|
|
|
|
|
|
|
{ |
114
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
115
|
0
|
|
|
|
|
|
my $path = $class->file(@_); |
116
|
0
|
0
|
|
|
|
|
return unless defined $path; |
117
|
0
|
0
|
|
|
|
|
$path .= ":" unless $path =~ /:$/; |
118
|
0
|
|
|
|
|
|
$path; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |