1 package URI::file::Mac;
3 require URI::file::Base;
4 @ISA=qw(URI::file::Base);
7 use URI::Escape qw(uri_unescape);
11 sub _file_extract_path
17 if ($path =~ s/^(:+)//) {
18 if (length($1) == 1) {
19 @pre = (".") unless length($path);
21 @pre = ("..") x (length($1) - 1);
27 my $isdir = ($path =~ s/:$//);
28 $path =~ s,([%/;]), URI::Escape::escape_char($1),eg;
30 my @path = split(/:/, $path, -1);
32 if ($_ eq "." || $_ eq "..") {
33 $_ = "%2E" x length($_);
35 $_ = ".." unless length($_);
37 push (@path,"") if $isdir;
38 (join("/", @pre, @path), 1);
48 my $auth = $uri->authority;
50 if (lc($auth) ne "localhost" && $auth ne "") {
51 my $u_auth = uri_unescape($auth);
52 if (!$class->_file_is_localhost($u_auth)) {
53 # some other host (use it as volume name)
55 # XXX or just return to make it illegal;
59 my @ps = split("/", $uri->path, -1);
65 return; # empty path; XXX return ":" instead?
66 } elsif ($path[0] eq "") {
70 return if $path[0] eq ""; # not root directory
71 push(@path, ""); # volume only, effectively append ":"
76 for (@ps) { #fix up "." and "..", including interior, in relatives
78 $part = $_ eq ".." ? "" : $_;
81 if ($ps[-1] eq "..") { #if this happens, we need another :
90 for (@ps) { #fix up "." and "..", including interior, in relatives
92 $part = $_ eq ".." ? "" : $_;
95 if ($ps[-1] eq "..") { #if this happens, we need another :
100 return unless $pre || @path;
102 s/;.*//; # get rid of parameters
103 #return unless length; # XXX
104 $_ = uri_unescape($_);
106 return if /:/; # Should we?
108 $pre . join(":", @path);
114 my $path = $class->file(@_);
115 return unless defined $path;
116 $path .= ":" unless $path =~ /:$/;