other versions
- wheezy 5.14.2-21+deb7u3
- jessie 5.20.2-3+deb8u6
- testing 5.24.1-3
- unstable 5.24.1-3
- experimental 5.26.0-1
other sections
File::Spec::Mac(3perl) | Perl Programmers Reference Guide | File::Spec::Mac(3perl) |
NAME¶
File::Spec::Mac - File::Spec for Mac OS (Classic)SYNOPSIS¶
require File::Spec::Mac; # Done internally by File::Spec if needed
DESCRIPTION¶
Methods for manipulating file specifications.METHODS¶
- canonpath
- On Mac OS, there's nothing to be done. Returns what it's given.
- catdir()
- Concatenate two or more directory names to form a path
separated by colons (":") ending with a directory. Resulting
paths are relative by default, but can be forced to be absolute
(but avoid this, see below). Automatically puts a trailing ":"
on the end of the complete path, because that's what's done in MacPerl's
environment and helps to distinguish a file path from a directory path.
catdir("a") = ":a:" catdir("a","b") = ":a:b:" catdir() = "" (special case)
catdir(":a:") = ":a:" catdir(":a","b") = ":a:b:" catdir(":a:","b") = ":a:b:" catdir(":a:",":b:") = ":a:b:" catdir(":") = ":"
- 1.
- The resulting path is relative by default, i.e. the resulting path will have a leading colon.
- 2.
- A trailing colon is added automatically to the resulting path, to denote a directory.
- 3.
- Generally, each argument has one leading ":" and one trailing ":" removed (if any). They are then joined together by a ":". Special treatment applies for arguments denoting updir paths like "::lib:", see (4), or arguments consisting solely of colons ("colon paths"), see (5).
- 4.
- When an updir path like ":::lib::" is passed as
argument, the number of directories to climb up is handled correctly, not
removing leading or trailing colons when necessary. E.g.
catdir(":::a","::b","c") = ":::a::b:c:" catdir(":::a::","::b","c") = ":::a:::b:c:"
- 5.
- Adding a colon ":" or empty string ""
to a path at any position doesn't alter the path, i.e. these
arguments are ignored. (When a "" is passed as the first
argument, it has a special meaning, see (6)). This way, a colon
":" is handled like a "." (curdir) on Unix, while an
empty string "" is generally ignored (see
"Unix->canonpath()" ). Likewise, a "::" is handled
like a ".." (updir), and a ":::" is handled like a
"../.." etc. E.g.
catdir("a",":",":","b") = ":a:b:" catdir("a",":","::",":b") = ":a::b:"
- 6.
- If the first argument is an empty string "" or is a volume name, i.e. matches the pattern /^[^:]+:/, the resulting path is absolute.
- 7.
- Passing an empty string "" as the first argument
to "catdir()" is like
passing"File::Spec->rootdir()" as the first argument, i.e.
catdir("","a","b") is the same as catdir(rootdir(),"a","b").
- 8.
- For absolute paths, some cleanup is done, to ensure that
the volume name isn't immediately followed by updirs. This is invalid,
because this would go beyond "root". Generally, these cases are
handled like their Unix counterparts:
Unix: Unix->catdir("","") = "/" Unix->catdir("",".") = "/" Unix->catdir("","..") = "/" # can't go beyond root Unix->catdir("",".","..","..","a") = "/a" Mac: Mac->catdir("","") = rootdir() # (e.g. "HD:") Mac->catdir("",":") = rootdir() Mac->catdir("","::") = rootdir() # can't go beyond root Mac->catdir("",":","::","::","a") = rootdir() . "a:" # (e.g. "HD:a:")
$dir = File::Spec->catdir("tmp","sources"); $abs_path = File::Spec->catpath("MacintoshHD:", $dir,"");
"MacintoshHD:tmp:sources:" .
- catfile
- Concatenate one or more directory names and a filename to
form a complete path ending with a filename. Resulting paths are
relative by default, but can be forced to be absolute (but avoid
this).
catfile("") = "" catfile("file") = "file"
catfile("","") = rootdir() # (e.g. "HD:") catfile("","file") = rootdir() . file # (e.g. "HD:file") catfile("HD:","file") = "HD:file"
catfile("a","b","file") = ":a:b:file" and catfile("a","b",":file") = ":a:b:file"
- curdir
- Returns a string representing the current directory. On Mac OS, this is ":".
- devnull
- Returns a string representing the null device. On Mac OS, this is "Dev:Null".
- rootdir
- Returns a string representing the root directory. Under
MacPerl, returns the name of the startup volume, since that's the closest
in concept, although other volumes aren't rooted there. The name has a
trailing ":", because that's the correct specification for a
volume name on Mac OS.
- tmpdir
- Returns the contents of $ENV{TMPDIR}, if that directory exits or the current working directory otherwise. Under MacPerl, $ENV{TMPDIR} will contain a path like "MacintoshHD:Temporary Items:", which is a hidden directory on your startup volume.
- updir
- Returns a string representing the parent directory. On Mac OS, this is "::".
- file_name_is_absolute
- Takes as argument a path and returns true, if it is an
absolute path. If the path has a leading ":", it's a relative
path. Otherwise, it's an absolute path, unless the path doesn't contain
any colons, i.e. it's a name like "a". In this particular case,
the path is considered to be relative (i.e. it is considered to be a
filename). Use ":" in the appropriate place in the path if you
want to distinguish unambiguously. As a special case, the filename '' is
always considered to be absolute. Note that with version 1.2 of
File::Spec::Mac, this does no longer consult the local filesystem.
File::Spec->file_name_is_absolute("a"); # false (relative) File::Spec->file_name_is_absolute(":a:b:"); # false (relative) File::Spec->file_name_is_absolute("MacintoshHD:"); # true (absolute) File::Spec->file_name_is_absolute(""); # true (absolute)
- path
- Returns the null list for the MacPerl application, since the concept is usually meaningless under Mac OS. But if you're using the MacPerl tool under MPW, it gives back $ENV{Commands} suitably split, as is done in :lib:ExtUtils:MM_Mac.pm.
- splitpath
-
($volume,$directories,$file) = File::Spec->splitpath( $path ); ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file );
- splitdir
- The opposite of "catdir()".
@dirs = File::Spec->splitdir( $directories );
File::Spec->splitdir( ":a:b::c:" ); and File::Spec->splitdir( ":a:b::c" );
( "a", "b", "::", "c")
File::Spec->splitdir( ":a:b::c::" );
( "a", "b", "::", "c", "::")
- catpath
-
$path = File::Spec->catpath($volume,$directory,$file);
- abs2rel
- Takes a destination path and an optional base path and
returns a relative path from the base path to the destination path:
$rel_path = File::Spec->abs2rel( $path ) ; $rel_path = File::Spec->abs2rel( $path, $base ) ;
- rel2abs
- Converts a relative path to an absolute path:
$abs_path = File::Spec->rel2abs( $path ) ; $abs_path = File::Spec->rel2abs( $path, $base ) ;
AUTHORS¶
See the authors list in File::Spec. Mac OS support by Paul Schinder <schinder@pobox.com> and Thomas Wegner <wegner_thomas@yahoo.com>.COPYRIGHT¶
Copyright (c) 2004 by the Perl 5 Porters. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.SEE ALSO¶
See File::Spec and File::Spec::Unix. This package overrides the implementation of these methods, not the semantics.2011-09-26 | perl v5.14.2 |