summaryrefslogtreecommitdiff
path: root/lib/File/Spec/Unix.pm
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2005-12-10 15:42:39 +0000
committerSteve Peters <steve@fisharerojo.org>2005-12-10 15:42:39 +0000
commitfa52125f2139574b06ddadadf21b82bb93e6c77e (patch)
treed27b282b23bdcda8a935ed3c7e189ed8f9f50d26 /lib/File/Spec/Unix.pm
parent00b6aa4170b1d4f8cd86fa0a48749312580e6806 (diff)
downloadperl-fa52125f2139574b06ddadadf21b82bb93e6c77e.tar.gz
Upgrade to PathTools-3.14_01
p4raw-id: //depot/perl@26318
Diffstat (limited to 'lib/File/Spec/Unix.pm')
-rw-r--r--lib/File/Spec/Unix.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm
index 55e6cc30f3..8be7329ffe 100644
--- a/lib/File/Spec/Unix.pm
+++ b/lib/File/Spec/Unix.pm
@@ -369,10 +369,22 @@ sub abs2rel {
my $path_directories = ($self->splitpath($path, 1))[1];
my $base_directories = ($self->splitpath($base, 1))[1];
+ # For UNC paths, the user might give a volume like //foo/bar that
+ # strictly speaking has no directory portion. Treat it as if it
+ # had the root directory for that volume.
+ if (!length($base_directories) and $self->file_name_is_absolute($base)) {
+ $base_directories = $self->rootdir;
+ }
+
# Now, remove all leading components that are the same
my @pathchunks = $self->splitdir( $path_directories );
my @basechunks = $self->splitdir( $base_directories );
+ if ($base_directories eq $self->rootdir) {
+ shift @pathchunks;
+ return $self->canonpath( $self->catpath('', $self->catdir( @pathchunks ), '') );
+ }
+
while (@pathchunks && @basechunks && $self->_same($pathchunks[0], $basechunks[0])) {
shift @pathchunks ;
shift @basechunks ;