summaryrefslogtreecommitdiff
path: root/lib/File
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-10-19 10:23:11 +0000
committerNicholas Clark <nick@ccl4.org>2008-10-19 10:23:11 +0000
commit486bcc50ba13b9bb0f294f39e26e6e0d78f5f1fe (patch)
treec408d2b20b5aaf9bf9a25827f8136478a75fdeca /lib/File
parent444c2e40cd0ea36b829c3148c73f26229f0ec7aa (diff)
downloadperl-486bcc50ba13b9bb0f294f39e26e6e0d78f5f1fe.tar.gz
Upgrade PathTools to 3.28_01
p4raw-id: //depot/perl@34514
Diffstat (limited to 'lib/File')
-rw-r--r--lib/File/Spec.pm2
-rw-r--r--lib/File/Spec/Cygwin.pm5
-rw-r--r--lib/File/Spec/Epoc.pm3
-rw-r--r--lib/File/Spec/Functions.pm3
-rw-r--r--lib/File/Spec/Mac.pm3
-rw-r--r--lib/File/Spec/OS2.pm3
-rw-r--r--lib/File/Spec/Unix.pm13
-rw-r--r--lib/File/Spec/VMS.pm35
-rw-r--r--lib/File/Spec/Win32.pm14
-rw-r--r--lib/File/Spec/t/Spec.t38
10 files changed, 92 insertions, 27 deletions
diff --git a/lib/File/Spec.pm b/lib/File/Spec.pm
index 53d4a5a22b..b4bcaeb4c1 100644
--- a/lib/File/Spec.pm
+++ b/lib/File/Spec.pm
@@ -3,7 +3,7 @@ package File::Spec;
use strict;
use vars qw(@ISA $VERSION);
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
$VERSION = eval $VERSION;
my %module = (MacOS => 'Mac',
diff --git a/lib/File/Spec/Cygwin.pm b/lib/File/Spec/Cygwin.pm
index 1b2c045960..89444f9bcb 100644
--- a/lib/File/Spec/Cygwin.pm
+++ b/lib/File/Spec/Cygwin.pm
@@ -4,7 +4,8 @@ use strict;
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
@ISA = qw(File::Spec::Unix);
@@ -111,7 +112,7 @@ Default: 1
=cut
-sub case_tolerant () {
+sub case_tolerant {
return 1 unless $^O eq 'cygwin'
and defined &Cygwin::mount_flags;
diff --git a/lib/File/Spec/Epoc.pm b/lib/File/Spec/Epoc.pm
index 1e0ad188bd..57d2ec2d95 100644
--- a/lib/File/Spec/Epoc.pm
+++ b/lib/File/Spec/Epoc.pm
@@ -3,7 +3,8 @@ package File::Spec::Epoc;
use strict;
use vars qw($VERSION @ISA);
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
require File::Spec::Unix;
@ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/Functions.pm b/lib/File/Spec/Functions.pm
index ab335e16a0..a6957632f5 100644
--- a/lib/File/Spec/Functions.pm
+++ b/lib/File/Spec/Functions.pm
@@ -5,7 +5,8 @@ use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
require Exporter;
diff --git a/lib/File/Spec/Mac.pm b/lib/File/Spec/Mac.pm
index 97fa676626..fdf35284f6 100644
--- a/lib/File/Spec/Mac.pm
+++ b/lib/File/Spec/Mac.pm
@@ -4,7 +4,8 @@ use strict;
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
@ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/OS2.pm b/lib/File/Spec/OS2.pm
index 48d09fa2f9..54dda3d050 100644
--- a/lib/File/Spec/OS2.pm
+++ b/lib/File/Spec/OS2.pm
@@ -4,7 +4,8 @@ use strict;
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
@ISA = qw(File::Spec::Unix);
diff --git a/lib/File/Spec/Unix.pm b/lib/File/Spec/Unix.pm
index e8dbaa9332..57b83c6cb4 100644
--- a/lib/File/Spec/Unix.pm
+++ b/lib/File/Spec/Unix.pm
@@ -3,7 +3,8 @@ package File::Spec::Unix;
use strict;
use vars qw($VERSION);
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
=head1 NAME
@@ -104,7 +105,7 @@ Returns a string representation of the current directory. "." on UNIX.
=cut
-sub curdir () { '.' }
+sub curdir { '.' }
=item devnull
@@ -112,7 +113,7 @@ Returns a string representation of the null device. "/dev/null" on UNIX.
=cut
-sub devnull () { '/dev/null' }
+sub devnull { '/dev/null' }
=item rootdir
@@ -120,7 +121,7 @@ Returns a string representation of the root directory. "/" on UNIX.
=cut
-sub rootdir () { '/' }
+sub rootdir { '/' }
=item tmpdir
@@ -169,7 +170,7 @@ Returns a string representation of the parent directory. ".." on UNIX.
=cut
-sub updir () { '..' }
+sub updir { '..' }
=item no_upwards
@@ -190,7 +191,7 @@ is not or is significant when comparing file specifications.
=cut
-sub case_tolerant () { 0 }
+sub case_tolerant { 0 }
=item file_name_is_absolute
diff --git a/lib/File/Spec/VMS.pm b/lib/File/Spec/VMS.pm
index 747a89d4fd..f68927d84e 100644
--- a/lib/File/Spec/VMS.pm
+++ b/lib/File/Spec/VMS.pm
@@ -4,7 +4,8 @@ use strict;
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
@ISA = qw(File::Spec::Unix);
@@ -242,16 +243,34 @@ sub file_name_is_absolute {
=item splitpath (override)
-Splits using VMS syntax.
+ ($volume,$directories,$file) = File::Spec->splitpath( $path );
+ ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file );
+
+Passing a true value for C<$no_file> indicates that the path being
+split only contains directory components, even on systems where you
+can usually (when not supporting a foreign syntax) tell the difference
+between directories and files at a glance.
=cut
sub splitpath {
- my($self,$path) = @_;
- my($dev,$dir,$file) = ('','','');
-
- vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s;
- return ($1 || '',$2 || '',$3);
+ my($self,$path, $nofile) = @_;
+ my($dev,$dir,$file) = ('','','');
+ my $vmsify_path = vmsify($path);
+ if ( $nofile ){
+ #vmsify('d1/d2/d3') returns '[.d1.d2]d3'
+ #vmsify('/d1/d2/d3') returns 'd1:[d2]d3'
+ if( $vmsify_path =~ /(.*)\](.+)/ ){
+ $vmsify_path = $1.'.'.$2.']';
+ }
+ $vmsify_path =~ /(.+:)?(.*)/s;
+ $dir = defined $2 ? $2 : ''; # dir can be '0'
+ return ($1 || '',$dir,$file);
+ }
+ else {
+ $vmsify_path =~ /(.+:)?([\[<].*[\]>])?(.*)/s;
+ return ($1 || '',$2 || '',$3);
+ }
}
=item splitdir (override)
@@ -470,7 +489,7 @@ sub eliminate_macros {
sub fixpath {
my($self,$path,$force_path) = @_;
return '' unless $path;
- $self = bless {} unless ref $self;
+ $self = bless {}, $self unless ref $self;
my($fixedpath,$prefix,$name);
if ($path =~ /\s/) {
diff --git a/lib/File/Spec/Win32.pm b/lib/File/Spec/Win32.pm
index 9b9034039f..4df45f686e 100644
--- a/lib/File/Spec/Win32.pm
+++ b/lib/File/Spec/Win32.pm
@@ -5,7 +5,8 @@ use strict;
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
@ISA = qw(File::Spec::Unix);
@@ -41,7 +42,7 @@ sub devnull {
return "nul";
}
-sub rootdir () { '\\' }
+sub rootdir { '\\' }
=item tmpdir
@@ -87,7 +88,7 @@ Default: 1
=cut
-sub case_tolerant () {
+sub case_tolerant {
eval { require Win32API::File; } or return 1;
my $drive = shift || "C:";
my $osFsType = "\0"x256;
@@ -375,9 +376,10 @@ implementation of these methods, not the semantics.
=cut
-sub _canon_cat(@) # @path -> path
+sub _canon_cat # @path -> path
{
- my $first = shift;
+ my ($first, @rest) = @_;
+
my $volume = $first =~ s{ \A ([A-Za-z]:) ([\\/]?) }{}x # drive letter
? ucfirst( $1 ).( $2 ? "\\" : "" )
: $first =~ s{ \A (?:\\\\|//) ([^\\/]+)
@@ -387,7 +389,7 @@ sub _canon_cat(@) # @path -> path
: $first =~ s{ \A [\\/] }{}x # root dir
? "\\"
: "";
- my $path = join "\\", $first, @_;
+ my $path = join "\\", $first, @rest;
$path =~ tr#\\/#\\\\#s; # xx/yy --> xx\yy & xx\\yy --> xx\yy
diff --git a/lib/File/Spec/t/Spec.t b/lib/File/Spec/t/Spec.t
index 83c22a6f61..6150bc33f9 100644
--- a/lib/File/Spec/t/Spec.t
+++ b/lib/File/Spec/t/Spec.t
@@ -312,6 +312,44 @@ if ($^O eq 'MacOS') {
[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
+[ "VMS->splitpath('[]')", ',[],' ],
+[ "VMS->splitpath('[-]')", ',[-],' ],
+[ "VMS->splitpath('[]file')", ',[],file' ],
+[ "VMS->splitpath('[-]file')", ',[-],file' ],
+[ "VMS->splitpath('')", ',,' ],
+[ "VMS->splitpath('0')", ',,0' ],
+[ "VMS->splitpath('[0]')", ',[0],' ],
+[ "VMS->splitpath('[.0]')", ',[.0],' ],
+[ "VMS->splitpath('[0.0.0]')", ',[0.0.0],' ],
+[ "VMS->splitpath('[.0.0.0]')", ',[.0.0.0],' ],
+[ "VMS->splitpath('[0]0')", ',[0],0' ],
+[ "VMS->splitpath('[0.0.0]0')", ',[0.0.0],0' ],
+[ "VMS->splitpath('[.0.0.0]0')", ',[.0.0.0],0' ],
+[ "VMS->splitpath('0/0')", ',[.0],0' ],
+[ "VMS->splitpath('0/0/0')", ',[.0.0],0' ],
+[ "VMS->splitpath('/0/0')", '0:,[000000],0' ],
+[ "VMS->splitpath('/0/0/0')", '0:,[0],0' ],
+[ "VMS->splitpath('d1',1)", ',d1,' ],
+# $no_file tests
+[ "VMS->splitpath('[d1.d2.d3]',1)", ',[d1.d2.d3],' ],
+[ "VMS->splitpath('[.d1.d2.d3]',1)", ',[.d1.d2.d3],' ],
+[ "VMS->splitpath('d1/d2/d3',1)", ',[.d1.d2.d3],' ],
+[ "VMS->splitpath('/d1/d2/d3',1)", 'd1:,[d2.d3],' ],
+[ "VMS->splitpath('node::volume:[d1.d2.d3]',1)", 'node::volume:,[d1.d2.d3],' ],
+[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]',1)", 'node"access_spec"::volume:,[d1.d2.d3],' ],
+[ "VMS->splitpath('[]',1)", ',[],' ],
+[ "VMS->splitpath('[-]',1)", ',[-],' ],
+[ "VMS->splitpath('',1)", ',,' ],
+[ "VMS->splitpath('0',1)", ',0,' ],
+[ "VMS->splitpath('[0]',1)", ',[0],' ],
+[ "VMS->splitpath('[.0]',1)", ',[.0],' ],
+[ "VMS->splitpath('[0.0.0]',1)", ',[0.0.0],' ],
+[ "VMS->splitpath('[.0.0.0]',1)", ',[.0.0.0],' ],
+[ "VMS->splitpath('0/0',1)", ',[.0.0],' ],
+[ "VMS->splitpath('0/0/0',1)", ',[.0.0.0],' ],
+[ "VMS->splitpath('/0/0',1)", '0:,[000000.0],' ],
+[ "VMS->splitpath('/0/0/0',1)", '0:,[0.0],' ],
+
[ "VMS->catpath('','','file')", 'file' ],
[ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ],
[ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ],