use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '3.2701';
+$VERSION = '3.28_01';
+$VERSION = eval $VERSION;
@ISA = qw(File::Spec::Unix);
=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)
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/) {
[ "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]' ],