From: Barrie Slaymaker Date: Mon, 12 Nov 2001 11:19:52 +0000 (-0500) Subject: remove volume from result X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b1c7707319e7631584ef9f5d258edf5657d488c;p=p5sagit%2Fp5-mst-13.2.git remove volume from result Message-ID: <20011112111948.C7626@sizzle.whoville.com> p4raw-id: //depot/perl@12957 --- diff --git a/lib/File/Spec.t b/lib/File/Spec.t index 71a0b7a..306a131 100755 --- a/lib/File/Spec.t +++ b/lib/File/Spec.t @@ -196,6 +196,9 @@ if ($^O eq 'MacOS') { [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\..\\..\\c' ], [ "Win32->canonpath('//a/../../c')", '\\\\a\\..\\..\\c' ], +## Hmmm, we should test missing and relative base paths some day... +## would need to cd to a known place, get the cwd() and use it I +## think. [ "Win32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ], [ "Win32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ], [ "Win32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], @@ -208,6 +211,8 @@ if ($^O eq 'MacOS') { [ "Win32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ], [ "Win32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '..\\t4' ], [ "Win32->abs2rel('//a/t1/t2/t4','/t2/t3')", '..\\t4' ], +[ "Win32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')",'' ], +[ "Win32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')",'t4' ], [ "Win32->rel2abs('temp','C:/')", 'C:\\temp' ], [ "Win32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ], diff --git a/lib/File/Spec/Win32.pm b/lib/File/Spec/Win32.pm index d2e94bc..ceebb2d 100644 --- a/lib/File/Spec/Win32.pm +++ b/lib/File/Spec/Win32.pm @@ -277,7 +277,7 @@ sub abs2rel { } # Split up paths - my ( $path_volume, $path_directories, $path_file ) = + my ( undef, $path_directories, $path_file ) = $self->splitpath( $path, 1 ) ; my $base_directories = ($self->splitpath( $base, 1 ))[1] ; @@ -315,11 +315,8 @@ sub abs2rel { $path_directories = "$base_directories$path_directories" ; } - # It makes no sense to add a relative path to a UNC volume - $path_volume = '' unless $path_volume =~ m{^[A-Z]:}is ; - return $self->canonpath( - $self->catpath($path_volume, $path_directories, $path_file ) + $self->catpath( "", $path_directories, $path_file ) ) ; }