summaryrefslogtreecommitdiff
path: root/lib/URI/file
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-11-11 06:55:13 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-11-11 06:55:13 +0000
commit3282be229999dc36c197b264d63063a18d136331 (patch)
tree98a42db29d955b39e7bed1b599fdcc56c3a29de9 /lib/URI/file
parentcfdd733c17cfa4f1a43b827a656e9e53cc2524ac (diff)
downloadxxv-3282be229999dc36c197b264d63063a18d136331.tar.gz
xxv-3282be229999dc36c197b264d63063a18d136331.tar.bz2
* Update installation list with required modules
* Remove unused/doubled provided external perl moduls
Diffstat (limited to 'lib/URI/file')
-rw-r--r--lib/URI/file/Base.pm80
-rw-r--r--lib/URI/file/FAT.pm23
-rw-r--r--lib/URI/file/Mac.pm120
-rw-r--r--lib/URI/file/OS2.pm28
-rw-r--r--lib/URI/file/QNX.pm18
-rw-r--r--lib/URI/file/Unix.pm55
-rw-r--r--lib/URI/file/Win32.pm84
7 files changed, 0 insertions, 408 deletions
diff --git a/lib/URI/file/Base.pm b/lib/URI/file/Base.pm
deleted file mode 100644
index 51030c2..0000000
--- a/lib/URI/file/Base.pm
+++ /dev/null
@@ -1,80 +0,0 @@
-package URI::file::Base;
-
-use strict;
-use URI::Escape qw();
-
-sub new
-{
- my $class = shift;
- my $path = shift;
- $path = "" unless defined $path;
-
- my($auth, $escaped_auth, $escaped_path);
-
- ($auth, $escaped_auth) = $class->_file_extract_authority($path);
- ($path, $escaped_path) = $class->_file_extract_path($path);
-
- if (defined $auth) {
- $auth =~ s,%,%25,g unless $escaped_auth;
- $auth =~ s,([/?\#]),$URI::Escape::escapes{$1},g;
- $auth = "//$auth";
- if (defined $path) {
- $path = "/$path" unless substr($path, 0, 1) eq "/";
- } else {
- $path = "";
- }
- } else {
- return undef unless defined $path;
- $auth = "";
- }
-
- $path =~ s,([%;?]),$URI::Escape::escapes{$1},g unless $escaped_path;
- $path =~ s/\#/%23/g;
-
- my $uri = $auth . $path;
- $uri = "file:$uri" if substr($uri, 0, 1) eq "/";
-
- URI->new($uri, "file");
-}
-
-sub _file_extract_authority
-{
- my($class, $path) = @_;
- return undef unless $class->_file_is_absolute($path);
- return $URI::file::DEFAULT_AUTHORITY;
-}
-
-sub _file_extract_path
-{
- return undef;
-}
-
-sub _file_is_absolute
-{
- return 0;
-}
-
-sub _file_is_localhost
-{
- shift; # class
- my $host = lc(shift);
- return 1 if $host eq "localhost";
- eval {
- require Net::Domain;
- lc(Net::Domain::hostfqdn()) eq $host ||
- lc(Net::Domain::hostname()) eq $host;
- };
-}
-
-sub file
-{
- undef;
-}
-
-sub dir
-{
- my $self = shift;
- $self->file(@_);
-}
-
-1;
diff --git a/lib/URI/file/FAT.pm b/lib/URI/file/FAT.pm
deleted file mode 100644
index 328169b..0000000
--- a/lib/URI/file/FAT.pm
+++ /dev/null
@@ -1,23 +0,0 @@
-package URI::file::FAT;
-
-require URI::file::Win32;
-@ISA=qw(URI::file::Win32);
-
-sub fix_path
-{
- shift; # class
- for (@_) {
- # turn it into 8.3 names
- my @p = map uc, split(/\./, $_, -1);
- return if @p > 2; # more than 1 dot is not allowed
- @p = ("") unless @p; # split bug? (returns nothing when splitting "")
- $_ = substr($p[0], 0, 8);
- if (@p > 1) {
- my $ext = substr($p[1], 0, 3);
- $_ .= ".$ext" if length $ext;
- }
- }
- 1; # ok
-}
-
-1;
diff --git a/lib/URI/file/Mac.pm b/lib/URI/file/Mac.pm
deleted file mode 100644
index 8eef34b..0000000
--- a/lib/URI/file/Mac.pm
+++ /dev/null
@@ -1,120 +0,0 @@
-package URI::file::Mac;
-
-require URI::file::Base;
-@ISA=qw(URI::file::Base);
-
-use strict;
-use URI::Escape qw(uri_unescape);
-
-
-
-sub _file_extract_path
-{
- my $class = shift;
- my $path = shift;
-
- my @pre;
- if ($path =~ s/^(:+)//) {
- if (length($1) == 1) {
- @pre = (".") unless length($path);
- } else {
- @pre = ("..") x (length($1) - 1);
- }
- } else { #absolute
- $pre[0] = "";
- }
-
- my $isdir = ($path =~ s/:$//);
- $path =~ s,([%/;]),$URI::Escape::escapes{$1},g;
-
- my @path = split(/:/, $path, -1);
- for (@path) {
- if ($_ eq "." || $_ eq "..") {
- $_ = "%2E" x length($_);
- }
- $_ = ".." unless length($_);
- }
- push (@path,"") if $isdir;
- (join("/", @pre, @path), 1);
-}
-
-
-sub file
-{
- my $class = shift;
- my $uri = shift;
- my @path;
-
- my $auth = $uri->authority;
- if (defined $auth) {
- if (lc($auth) ne "localhost" && $auth ne "") {
- my $u_auth = uri_unescape($auth);
- if (!$class->_file_is_localhost($u_auth)) {
- # some other host (use it as volume name)
- @path = ("", $auth);
- # XXX or just return to make it illegal;
- }
- }
- }
- my @ps = split("/", $uri->path, -1);
- shift @ps if @path;
- push(@path, @ps);
-
- my $pre = "";
- if (!@path) {
- return; # empty path; XXX return ":" instead?
- } elsif ($path[0] eq "") {
- # absolute
- shift(@path);
- if (@path == 1) {
- return if $path[0] eq ""; # not root directory
- push(@path, ""); # volume only, effectively append ":"
- }
- @ps = @path;
- @path = ();
- my $part;
- for (@ps) { #fix up "." and "..", including interior, in relatives
- next if $_ eq ".";
- $part = $_ eq ".." ? "" : $_;
- push(@path,$part);
- }
- if ($ps[-1] eq "..") { #if this happens, we need another :
- push(@path,"");
- }
-
- } else {
- $pre = ":";
- @ps = @path;
- @path = ();
- my $part;
- for (@ps) { #fix up "." and "..", including interior, in relatives
- next if $_ eq ".";
- $part = $_ eq ".." ? "" : $_;
- push(@path,$part);
- }
- if ($ps[-1] eq "..") { #if this happens, we need another :
- push(@path,"");
- }
-
- }
- return unless $pre || @path;
- for (@path) {
- s/;.*//; # get rid of parameters
- #return unless length; # XXX
- $_ = uri_unescape($_);
- return if /\0/;
- return if /:/; # Should we?
- }
- $pre . join(":", @path);
-}
-
-sub dir
-{
- my $class = shift;
- my $path = $class->file(@_);
- return unless defined $path;
- $path .= ":" unless $path =~ /:$/;
- $path;
-}
-
-1;
diff --git a/lib/URI/file/OS2.pm b/lib/URI/file/OS2.pm
deleted file mode 100644
index ad0a78e..0000000
--- a/lib/URI/file/OS2.pm
+++ /dev/null
@@ -1,28 +0,0 @@
-package URI::file::OS2;
-
-require URI::file::Win32;
-@ISA=qw(URI::file::Win32);
-
-# The Win32 version translates k:/foo to file://k:/foo (?!)
-# We add an empty host
-
-sub _file_extract_authority
-{
- my $class = shift;
- return $1 if $_[0] =~ s,^\\\\([^\\]+),,; # UNC
- return $1 if $_[0] =~ s,^//([^/]+),,; # UNC too?
-
- if ($_[0] =~ m#^[a-zA-Z]{1,2}:#) { # allow for ab: drives
- return "";
- }
- return;
-}
-
-sub file {
- my $p = &URI::file::Win32::file;
- return unless defined $p;
- $p =~ s,\\,/,g;
- $p;
-}
-
-1;
diff --git a/lib/URI/file/QNX.pm b/lib/URI/file/QNX.pm
deleted file mode 100644
index 93a4983..0000000
--- a/lib/URI/file/QNX.pm
+++ /dev/null
@@ -1,18 +0,0 @@
-package URI::file::QNX;
-
-require URI::file::Unix;
-@ISA=qw(URI::file::Unix);
-
-use strict;
-
-sub _file_extract_path
-{
- my($class, $path) = @_;
- # tidy path
- $path =~ s,(.)//+,$1/,g; # ^// is correct
- $path =~ s,(/\.)+/,/,g;
- $path = "./$path" if $path =~ m,^[^:/]+:,,; # look like "scheme:"
- $path;
-}
-
-1;
diff --git a/lib/URI/file/Unix.pm b/lib/URI/file/Unix.pm
deleted file mode 100644
index 5f8aaae..0000000
--- a/lib/URI/file/Unix.pm
+++ /dev/null
@@ -1,55 +0,0 @@
-package URI::file::Unix;
-
-require URI::file::Base;
-@ISA=qw(URI::file::Base);
-
-use strict;
-use URI::Escape qw(uri_unescape);
-
-sub _file_extract_path
-{
- my($class, $path) = @_;
-
- # tidy path
- $path =~ s,//+,/,g;
- $path =~ s,(/\.)+/,/,g;
- $path = "./$path" if $path =~ m,^[^:/]+:,,; # look like "scheme:"
-
- return $path;
-}
-
-sub _file_is_absolute {
- my($class, $path) = @_;
- return $path =~ m,^/,;
-}
-
-sub file
-{
- my $class = shift;
- my $uri = shift;
- my @path;
-
- my $auth = $uri->authority;
- if (defined($auth)) {
- if (lc($auth) ne "localhost" && $auth ne "") {
- $auth = uri_unescape($auth);
- unless ($class->_file_is_localhost($auth)) {
- push(@path, "", "", $auth);
- }
- }
- }
-
- my @ps = $uri->path_segments;
- shift @ps if @path;
- push(@path, @ps);
-
- for (@path) {
- # Unix file/directory names are not allowed to contain '\0' or '/'
- return undef if /\0/;
- return undef if /\//; # should we really?
- }
-
- return join("/", @path);
-}
-
-1;
diff --git a/lib/URI/file/Win32.pm b/lib/URI/file/Win32.pm
deleted file mode 100644
index 0459386..0000000
--- a/lib/URI/file/Win32.pm
+++ /dev/null
@@ -1,84 +0,0 @@
-package URI::file::Win32;
-
-require URI::file::Base;
-@ISA=qw(URI::file::Base);
-
-use strict;
-use URI::Escape qw(uri_unescape);
-
-sub _file_extract_authority
-{
- my $class = shift;
-
- return $class->SUPER::_file_extract_authority($_[0])
- if defined $URI::file::DEFAULT_AUTHORITY;
-
- return $1 if $_[0] =~ s,^\\\\([^\\]+),,; # UNC
- return $1 if $_[0] =~ s,^//([^/]+),,; # UNC too?
-
- if ($_[0] =~ s,^([a-zA-Z]:),,) {
- my $auth = $1;
- $auth .= "relative" if $_[0] !~ m,^[\\/],;
- return $auth;
- }
- return undef;
-}
-
-sub _file_extract_path
-{
- my($class, $path) = @_;
- $path =~ s,\\,/,g;
- #$path =~ s,//+,/,g;
- $path =~ s,(/\.)+/,/,g;
-
- if (defined $URI::file::DEFAULT_AUTHORITY) {
- $path =~ s,^([a-zA-Z]:),/$1,;
- }
-
- return $path;
-}
-
-sub _file_is_absolute {
- my($class, $path) = @_;
- return $path =~ m,^[a-zA-Z]:, || $path =~ m,^[/\\],;
-}
-
-sub file
-{
- my $class = shift;
- my $uri = shift;
- my $auth = $uri->authority;
- my $rel; # is filename relative to drive specified in authority
- if (defined $auth) {
- $auth = uri_unescape($auth);
- if ($auth =~ /^([a-zA-Z])[:|](relative)?/) {
- $auth = uc($1) . ":";
- $rel++ if $2;
- } elsif (lc($auth) eq "localhost") {
- $auth = "";
- } elsif (length $auth) {
- $auth = "\\\\" . $auth; # UNC
- }
- } else {
- $auth = "";
- }
-
- my @path = $uri->path_segments;
- for (@path) {
- return undef if /\0/;
- return undef if /\//;
- #return undef if /\\/; # URLs with "\" is not uncommon
- }
- return undef unless $class->fix_path(@path);
-
- my $path = join("\\", @path);
- $path =~ s/^\\// if $rel;
- $path = $auth . $path;
- $path =~ s,^\\([a-zA-Z])[:|],\u$1:,;
-
- return $path;
-}
-
-sub fix_path { 1; }
-
-1;