1 package URI::file::Win32;
3 require URI::file::Base;
4 @ISA=qw(URI::file::Base);
7 use URI::Escape qw(uri_unescape);
9 sub _file_extract_authority
13 return $class->SUPER::_file_extract_authority($_[0])
14 if defined $URI::file::DEFAULT_AUTHORITY;
16 return $1 if $_[0] =~ s,^\\\\([^\\]+),,; # UNC
17 return $1 if $_[0] =~ s,^//([^/]+),,; # UNC too?
19 if ($_[0] =~ s,^([a-zA-Z]:),,) {
21 $auth .= "relative" if $_[0] !~ m,^[\\/],;
27 sub _file_extract_path
29 my($class, $path) = @_;
32 $path =~ s,(/\.)+/,/,g;
34 if (defined $URI::file::DEFAULT_AUTHORITY) {
35 $path =~ s,^([a-zA-Z]:),/$1,;
41 sub _file_is_absolute {
42 my($class, $path) = @_;
43 return $path =~ m,^[a-zA-Z]:, || $path =~ m,^[/\\],;
50 my $auth = $uri->authority;
51 my $rel; # is filename relative to drive specified in authority
53 $auth = uri_unescape($auth);
54 if ($auth =~ /^([a-zA-Z])[:|](relative)?/) {
57 } elsif (lc($auth) eq "localhost") {
59 } elsif (length $auth) {
60 $auth = "\\\\" . $auth; # UNC
66 my @path = $uri->path_segments;
70 #return undef if /\\/; # URLs with "\" is not uncommon
72 return undef unless $class->fix_path(@path);
74 my $path = join("\\", @path);
75 $path =~ s/^\\// if $rel;
76 $path = $auth . $path;
77 $path =~ s,^\\([a-zA-Z])[:|],\u$1:,;