1N/Apackage File::Spec;
1N/A
1N/Ause strict;
1N/Ause vars qw(@ISA $VERSION);
1N/A
1N/A$VERSION = '0.87';
1N/A
1N/Amy %module = (MacOS => 'Mac',
1N/A MSWin32 => 'Win32',
1N/A os2 => 'OS2',
1N/A VMS => 'VMS',
1N/A epoc => 'Epoc',
1N/A NetWare => 'Win32', # Yes, File::Spec::Win32 works on NetWare.
1N/A dos => 'OS2', # Yes, File::Spec::OS2 works on DJGPP.
1N/A cygwin => 'Cygwin');
1N/A
1N/A
1N/Amy $module = $module{$^O} || 'Unix';
1N/A
1N/Arequire "File/Spec/$module.pm";
1N/A@ISA = ("File::Spec::$module");
1N/A
1N/A1;
1N/A
1N/A__END__
1N/A
1N/A=head1 NAME
1N/A
1N/AFile::Spec - portably perform operations on file names
1N/A
1N/A=head1 SYNOPSIS
1N/A
1N/A use File::Spec;
1N/A
1N/A $x=File::Spec->catfile('a', 'b', 'c');
1N/A
1N/Awhich returns 'a/b/c' under Unix. Or:
1N/A
1N/A use File::Spec::Functions;
1N/A
1N/A $x = catfile('a', 'b', 'c');
1N/A
1N/A=head1 DESCRIPTION
1N/A
1N/AThis module is designed to support operations commonly performed on file
1N/Aspecifications (usually called "file names", but not to be confused with the
1N/Acontents of a file, or Perl's file handles), such as concatenating several
1N/Adirectory and file names into a single path, or determining whether a path
1N/Ais rooted. It is based on code directly taken from MakeMaker 5.17, code
1N/Awritten by Andreas KE<ouml>nig, Andy Dougherty, Charles Bailey, Ilya
1N/AZakharevich, Paul Schinder, and others.
1N/A
1N/ASince these functions are different for most operating systems, each set of
1N/AOS specific routines is available in a separate module, including:
1N/A
1N/A File::Spec::Unix
1N/A File::Spec::Mac
1N/A File::Spec::OS2
1N/A File::Spec::Win32
1N/A File::Spec::VMS
1N/A
1N/AThe module appropriate for the current OS is automatically loaded by
1N/AFile::Spec. Since some modules (like VMS) make use of facilities available
1N/Aonly under that OS, it may not be possible to load all modules under all
1N/Aoperating systems.
1N/A
1N/ASince File::Spec is object oriented, subroutines should not be called directly,
1N/Aas in:
1N/A
1N/A File::Spec::catfile('a','b');
1N/A
1N/Abut rather as class methods:
1N/A
1N/A File::Spec->catfile('a','b');
1N/A
1N/AFor simple uses, L<File::Spec::Functions> provides convenient functional
1N/Aforms of these methods.
1N/A
1N/A=head1 METHODS
1N/A
1N/A=over 2
1N/A
1N/A=item canonpath
1N/A
1N/ANo physical check on the filesystem, but a logical cleanup of a
1N/Apath.
1N/A
1N/A $cpath = File::Spec->canonpath( $path ) ;
1N/A
1N/A=item catdir
1N/A
1N/AConcatenate two or more directory names to form a complete path ending
1N/Awith a directory. But remove the trailing slash from the resulting
1N/Astring, because it doesn't look good, isn't necessary and confuses
1N/AOS2. Of course, if this is the root directory, don't cut off the
1N/Atrailing slash :-)
1N/A
1N/A $path = File::Spec->catdir( @directories );
1N/A
1N/A=item catfile
1N/A
1N/AConcatenate one or more directory names and a filename to form a
1N/Acomplete path ending with a filename
1N/A
1N/A $path = File::Spec->catfile( @directories, $filename );
1N/A
1N/A=item curdir
1N/A
1N/AReturns a string representation of the current directory.
1N/A
1N/A $curdir = File::Spec->curdir();
1N/A
1N/A=item devnull
1N/A
1N/AReturns a string representation of the null device.
1N/A
1N/A $devnull = File::Spec->devnull();
1N/A
1N/A=item rootdir
1N/A
1N/AReturns a string representation of the root directory.
1N/A
1N/A $rootdir = File::Spec->rootdir();
1N/A
1N/A=item tmpdir
1N/A
1N/AReturns a string representation of the first writable directory from a
1N/Alist of possible temporary directories. Returns the current directory
1N/Aif no writable temporary directories are found. The list of directories
1N/Achecked depends on the platform; e.g. File::Spec::Unix checks $ENV{TMPDIR}
1N/A(unless taint is on) and /tmp.
1N/A
1N/A $tmpdir = File::Spec->tmpdir();
1N/A
1N/A=item updir
1N/A
1N/AReturns a string representation of the parent directory.
1N/A
1N/A $updir = File::Spec->updir();
1N/A
1N/A=item no_upwards
1N/A
1N/AGiven a list of file names, strip out those that refer to a parent
1N/Adirectory. (Does not strip symlinks, only '.', '..', and equivalents.)
1N/A
1N/A @paths = File::Spec->no_upwards( @paths );
1N/A
1N/A=item case_tolerant
1N/A
1N/AReturns a true or false value indicating, respectively, that alphabetic
1N/Ais not or is significant when comparing file specifications.
1N/A
1N/A $is_case_tolerant = File::Spec->case_tolerant();
1N/A
1N/A=item file_name_is_absolute
1N/A
1N/ATakes as argument a path and returns true if it is an absolute path.
1N/A
1N/A $is_absolute = File::Spec->file_name_is_absolute( $path );
1N/A
1N/AThis does not consult the local filesystem on Unix, Win32, OS/2, or
1N/AMac OS (Classic). It does consult the working environment for VMS
1N/A(see L<File::Spec::VMS/file_name_is_absolute>).
1N/A
1N/A=item path
1N/A
1N/ATakes no argument, returns the environment variable PATH (or the local
1N/Aplatform's equivalent) as a list.
1N/A
1N/A @PATH = File::Spec->path();
1N/A
1N/A=item join
1N/A
1N/Ajoin is the same as catfile.
1N/A
1N/A=item splitpath
1N/A
1N/ASplits a path in to volume, directory, and filename portions. On systems
1N/Awith no concept of volume, returns '' for volume.
1N/A
1N/A ($volume,$directories,$file) = File::Spec->splitpath( $path );
1N/A ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file );
1N/A
1N/AFor systems with no syntax differentiating filenames from directories,
1N/Aassumes that the last file is a path unless $no_file is true or a
1N/Atrailing separator or /. or /.. is present. On Unix this means that $no_file
1N/Atrue makes this return ( '', $path, '' ).
1N/A
1N/AThe directory portion may or may not be returned with a trailing '/'.
1N/A
1N/AThe results can be passed to L</catpath()> to get back a path equivalent to
1N/A(usually identical to) the original path.
1N/A
1N/A=item splitdir
1N/A
1N/AThe opposite of L</catdir()>.
1N/A
1N/A @dirs = File::Spec->splitdir( $directories );
1N/A
1N/A$directories must be only the directory portion of the path on systems
1N/Athat have the concept of a volume or that have path syntax that differentiates
1N/Afiles from directories.
1N/A
1N/AUnlike just splitting the directories on the separator, empty
1N/Adirectory names (C<''>) can be returned, because these are significant
1N/Aon some OSs.
1N/A
1N/A=item catpath()
1N/A
1N/ATakes volume, directory and file portions and returns an entire path. Under
1N/AUnix, $volume is ignored, and directory and file are concatenated. A '/' is
1N/Ainserted if need be. On other OSs, $volume is significant.
1N/A
1N/A $full_path = File::Spec->catpath( $volume, $directory, $file );
1N/A
1N/A=item abs2rel
1N/A
1N/ATakes a destination path and an optional base path returns a relative path
1N/Afrom the base path to the destination path:
1N/A
1N/A $rel_path = File::Spec->abs2rel( $path ) ;
1N/A $rel_path = File::Spec->abs2rel( $path, $base ) ;
1N/A
1N/AIf $base is not present or '', then L<cwd()|Cwd> is used. If $base is
1N/Arelative, then it is converted to absolute form using
1N/AL</rel2abs()>. This means that it is taken to be relative to
1N/AL<cwd()|Cwd>.
1N/A
1N/AOn systems with the concept of volume, if $path and $base appear to be
1N/Aon two different volumes, we will not attempt to resolve the two
1N/Apaths, and we will instead simply return $path. Note that previous
1N/Aversions of this module ignored the volume of $base, which resulted in
1N/Agarbage results part of the time.
1N/A
1N/AOn systems that have a grammar that indicates filenames, this ignores the
1N/A$base filename as well. Otherwise all path components are assumed to be
1N/Adirectories.
1N/A
1N/AIf $path is relative, it is converted to absolute form using L</rel2abs()>.
1N/AThis means that it is taken to be relative to L<cwd()|Cwd>.
1N/A
1N/ANo checks against the filesystem are made. On VMS, there is
1N/Ainteraction with the working environment, as logicals and
1N/Amacros are expanded.
1N/A
1N/ABased on code written by Shigio Yamaguchi.
1N/A
1N/A=item rel2abs()
1N/A
1N/AConverts a relative path to an absolute path.
1N/A
1N/A $abs_path = File::Spec->rel2abs( $path ) ;
1N/A $abs_path = File::Spec->rel2abs( $path, $base ) ;
1N/A
1N/AIf $base is not present or '', then L<cwd()|Cwd> is used. If $base is relative,
1N/Athen it is converted to absolute form using L</rel2abs()>. This means that it
1N/Ais taken to be relative to L<cwd()|Cwd>.
1N/A
1N/AOn systems with the concept of volume, if $path and $base appear to be
1N/Aon two different volumes, we will not attempt to resolve the two
1N/Apaths, and we will instead simply return $path. Note that previous
1N/Aversions of this module ignored the volume of $base, which resulted in
1N/Agarbage results part of the time.
1N/A
1N/AOn systems that have a grammar that indicates filenames, this ignores the
1N/A$base filename as well. Otherwise all path components are assumed to be
1N/Adirectories.
1N/A
1N/AIf $path is absolute, it is cleaned up and returned using L</canonpath()>.
1N/A
1N/ANo checks against the filesystem are made. On VMS, there is
1N/Ainteraction with the working environment, as logicals and
1N/Amacros are expanded.
1N/A
1N/ABased on code written by Shigio Yamaguchi.
1N/A
1N/A=back
1N/A
1N/AFor further information, please see L<File::Spec::Unix>,
1N/AL<File::Spec::Mac>, L<File::Spec::OS2>, L<File::Spec::Win32>, or
1N/AL<File::Spec::VMS>.
1N/A
1N/A=head1 SEE ALSO
1N/A
1N/AL<File::Spec::Unix>, L<File::Spec::Mac>, L<File::Spec::OS2>,
1N/AL<File::Spec::Win32>, L<File::Spec::VMS>, L<File::Spec::Functions>,
1N/AL<ExtUtils::MakeMaker>
1N/A
1N/A=head1 AUTHORS
1N/A
1N/AKenneth Albanowski <kjahds@kjahds.com>, Andy Dougherty
1N/A<doughera@lafayette.edu>, Andreas KE<ouml>nig
1N/A<A.Koenig@franz.ww.TU-Berlin.DE>, Tim Bunce <Tim.Bunce@ig.co.uk.
1N/AVMS support by Charles Bailey <bailey@newman.upenn.edu>.
1N/AOS/2 support by Ilya Zakharevich <ilya@math.ohio-state.edu>.
1N/AMac support by Paul Schinder <schinder@pobox.com>, and Thomas Wegner
1N/A<wegner_thomas@yahoo.com>. abs2rel() and rel2abs() written by Shigio
1N/AYamaguchi <shigio@tamacom.com>, modified by Barrie Slaymaker
1N/A<barries@slaysys.com>. splitpath(), splitdir(), catpath() and
1N/Acatdir() by Barrie Slaymaker.
1N/A
1N/A=cut