X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FFile%2FSpec.pm;h=c43576b5fa95ddfc7c84f38fe9757eddc7d51aa1;hb=f93bb41e64f81800210e18ffedb5ed633e362495;hp=19475c0321c1c3d3f1d60345fd04ea0ee56388df;hpb=ae1c33a12ee494201f28544af6904511e08ac3db;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/File/Spec.pm b/lib/File/Spec.pm index 19475c0..c43576b 100644 --- a/lib/File/Spec.pm +++ b/lib/File/Spec.pm @@ -1,17 +1,22 @@ package File::Spec; use strict; -our(@ISA, $VERSION); +use vars qw(@ISA $VERSION); -$VERSION = 0.82 ; +$VERSION = '0.86'; my %module = (MacOS => 'Mac', MSWin32 => 'Win32', os2 => 'OS2', VMS => 'VMS', - epoc => 'Epoc'); + epoc => 'Epoc', + NetWare => 'Win32', # Yes, File::Spec::Win32 works on NetWare. + dos => 'OS2', # Yes, File::Spec::OS2 works on DJGPP. + cygwin => 'Cygwin'); + my $module = $module{$^O} || 'Unix'; + require "File/Spec/$module.pm"; @ISA = ("File::Spec::$module"); @@ -59,7 +64,7 @@ File::Spec. Since some modules (like VMS) make use of facilities available only under that OS, it may not be possible to load all modules under all operating systems. -Since File::Spec is object oriented, subroutines should not called directly, +Since File::Spec is object oriented, subroutines should not be called directly, as in: File::Spec::catfile('a','b'); @@ -120,10 +125,10 @@ Returns a string representation of the root directory. =item tmpdir Returns a string representation of the first writable directory from a -list of possible temporary directories. Returns "" if no writable -temporary directories are found. The list of directories checked -depends on the platform; e.g. File::Spec::Unix checks $ENV{TMPDIR} and -/tmp. +list of possible temporary directories. Returns the current directory +if no writable temporary directories are found. The list of directories +checked depends on the platform; e.g. File::Spec::Unix checks $ENV{TMPDIR} +(unless taint is on) and /tmp. $tmpdir = File::Spec->tmpdir(); @@ -153,10 +158,9 @@ Takes as argument a path and returns true if it is an absolute path. $is_absolute = File::Spec->file_name_is_absolute( $path ); -This does not consult the local filesystem on Unix, Win32, or OS/2. It -does sometimes on MacOS (see L). -It does consult the working environment for VMS (see -L). +This does not consult the local filesystem on Unix, Win32, OS/2, or +Mac OS (Classic). It does consult the working environment for VMS +(see L). =item path @@ -171,7 +175,7 @@ join is the same as catfile. =item splitpath Splits a path in to volume, directory, and filename portions. On systems -with no concept of volume, returns undef for volume. +with no concept of volume, returns '' for volume. ($volume,$directories,$file) = File::Spec->splitpath( $path ); ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file ); @@ -198,12 +202,12 @@ files from directories. Unlike just splitting the directories on the separator, empty directory names (C<''>) can be returned, because these are significant -on some OSs (e.g. MacOS). +on some OSs. -=item catpath +=item catpath() Takes volume, directory and file portions and returns an entire path. Under -Unix, $volume is ignored, and directory and file are catenated. A '/' is +Unix, $volume is ignored, and directory and file are concatenated. A '/' is inserted if need be. On other OSs, $volume is significant. $full_path = File::Spec->catpath( $volume, $directory, $file ); @@ -216,9 +220,9 @@ from the base path to the destination path: $rel_path = File::Spec->abs2rel( $path ) ; $rel_path = File::Spec->abs2rel( $path, $base ) ; -If $base is not present or '', then L is used. If $base is relative, +If $base is not present or '', then L is used. If $base is relative, then it is converted to absolute form using L. This means that it -is taken to be relative to L. +is taken to be relative to L. On systems with the concept of a volume, this assumes that both paths are on the $destination volume, and ignores the $base volume. @@ -228,26 +232,24 @@ $base filename as well. Otherwise all path components are assumed to be directories. If $path is relative, it is converted to absolute form using L. -This means that it is taken to be relative to L. +This means that it is taken to be relative to L. -No checks against the filesystem are made on most systems. On MacOS, -the filesystem may be consulted (see -L). On VMS, there is +No checks against the filesystem are made. On VMS, there is interaction with the working environment, as logicals and macros are expanded. Based on code written by Shigio Yamaguchi. -=item rel2abs +=item rel2abs() Converts a relative path to an absolute path. $abs_path = File::Spec->rel2abs( $path ) ; $abs_path = File::Spec->rel2abs( $path, $base ) ; -If $base is not present or '', then L is used. If $base is relative, +If $base is not present or '', then L is used. If $base is relative, then it is converted to absolute form using L. This means that it -is taken to be relative to L. +is taken to be relative to L. On systems with the concept of a volume, this assumes that both paths are on the $base volume, and ignores the $path volume. @@ -258,9 +260,7 @@ directories. If $path is absolute, it is cleaned up and returned using L. -No checks against the filesystem are made on most systems. On MacOS, -the filesystem may be consulted (see -L). On VMS, there is +No checks against the filesystem are made. On VMS, there is interaction with the working environment, as logicals and macros are expanded. @@ -281,11 +281,14 @@ L =head1 AUTHORS Kenneth Albanowski , Andy Dougherty -, Andreas KEnig -, Tim Bunce . OS/2 support by -Ilya Zakharevich . Mac support by Paul Schinder -. abs2rel() and rel2abs() written by -Shigio Yamaguchi , modified by Barrie Slaymaker -. splitpath(), splitdir(), catpath() and catdir() -by Barrie Slaymaker. +, Andreas KEnig +, Tim Bunce . +OS/2 support by Ilya Zakharevich . +Mac support by Paul Schinder , and Thomas Wegner +. abs2rel() and rel2abs() written by Shigio +Yamaguchi , modified by Barrie Slaymaker +. splitpath(), splitdir(), catpath() and +catdir() by Barrie Slaymaker. + +=cut