Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / man3 / File::Spec::Mac.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "File::Spec::Mac 3"
.TH File::Spec::Mac 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
.SH "NAME"
File::Spec::Mac \- File::Spec for Mac OS (Classic)
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& require File::Spec::Mac; # Done internally by File::Spec if needed
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Methods for manipulating file specifications.
.SH "METHODS"
.IX Header "METHODS"
.IP "canonpath" 2
.IX Item "canonpath"
On Mac \s-1OS\s0, there's nothing to be done. Returns what it's given.
.IP "\fIcatdir()\fR" 2
.IX Item "catdir()"
Concatenate two or more directory names to form a path separated by colons
(\*(L":\*(R") ending with a directory. Resulting paths are \fBrelative\fR by default,
but can be forced to be absolute (but avoid this, see below). Automatically
puts a trailing \*(L":\*(R" 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.
.Sp
\&\fB\s-1IMPORTANT\s0 \s-1NOTE:\s0\fR Beginning with version 1.3 of this module, the resulting
path is relative by default and \fInot\fR absolute. This decision was made due
to portability reasons. Since \f(CW\*(C`File::Spec\->catdir()\*(C'\fR returns relative paths
on all other operating systems, it will now also follow this convention on Mac
\&\s-1OS\s0. Note that this may break some existing scripts.
.Sp
The intended purpose of this routine is to concatenate \fIdirectory names\fR.
But because of the nature of Macintosh paths, some additional possibilities
are allowed to make using this routine give reasonable results for some
common situations. In other words, you are also allowed to concatenate
\&\fIpaths\fR instead of directory names (strictly speaking, a string like \*(L":a\*(R"
is a path, but not a name, since it contains a punctuation character \*(L":\*(R").
.Sp
So, beside calls like
.Sp
.Vb 3
\& catdir("a") = ":a:"
\& catdir("a","b") = ":a:b:"
\& catdir() = "" (special case)
.Ve
.Sp
calls like the following
.Sp
.Vb 5
\& catdir(":a:") = ":a:"
\& catdir(":a","b") = ":a:b:"
\& catdir(":a:","b") = ":a:b:"
\& catdir(":a:",":b:") = ":a:b:"
\& catdir(":") = ":"
.Ve
.Sp
are allowed.
.Sp
Here are the rules that are used in \f(CW\*(C`catdir()\*(C'\fR; note that we try to be as
compatible as possible to Unix:
.RS 2
.IP "1." 2
The resulting path is relative by default, i.e. the resulting path will have a
leading colon.
.IP "2." 2
A trailing colon is added automatically to the resulting path, to denote a
directory.
.IP "3." 2
Generally, each argument has one leading \*(L":\*(R" and one trailing \*(L":\*(R"
removed (if any). They are then joined together by a \*(L":\*(R". Special
treatment applies for arguments denoting updir paths like \*(L"::lib:\*(R",
see (4), or arguments consisting solely of colons (\*(L"colon paths\*(R"),
see (5).
.IP "4." 2
When an updir path like \*(L":::lib::\*(R" is passed as argument, the number
of directories to climb up is handled correctly, not removing leading
or trailing colons when necessary. E.g.
.Sp
.Vb 2
\& catdir(":::a","::b","c") = ":::a::b:c:"
\& catdir(":::a::","::b","c") = ":::a:::b:c:"
.Ve
.IP "5." 2
Adding a colon \*(L":\*(R" or empty string "" to a path at \fIany\fR position
doesn't alter the path, i.e. these arguments are ignored. (When a "\*(L"
is passed as the first argument, it has a special meaning, see
(6)). This way, a colon \*(R":\*(L" is handled like a \*(R".\*(L" (curdir) on Unix,
while an empty string \*(R"" is generally ignored (see
\&\f(CW\*(C`Unix\->canonpath()\*(C'\fR ). Likewise, a \*(L"::\*(R" is handled like a \*(L"..\*(R"
(updir), and a \*(L":::\*(R" is handled like a \*(L"../..\*(R" etc. E.g.
.Sp
.Vb 2
\& catdir("a",":",":","b") = ":a:b:"
\& catdir("a",":","::",":b") = ":a::b:"
.Ve
.IP "6." 2
If the first argument is an empty string "" or is a volume name, i.e. matches
the pattern /^[^:]+:/, the resulting path is \fBabsolute\fR.
.IP "7." 2
Passing an empty string "" as the first argument to \f(CW\*(C`catdir()\*(C'\fR is
like passing\f(CW\*(C`File::Spec\->rootdir()\*(C'\fR as the first argument, i.e.
.Sp
.Vb 1
\& catdir("","a","b") is the same as
.Ve
.Sp
.Vb 1
\& catdir(rootdir(),"a","b").
.Ve
.Sp
This is true on Unix, where \f(CW\*(C`catdir("","a","b")\*(C'\fR yields \*(L"/a/b\*(R" and
\&\f(CW\*(C`rootdir()\*(C'\fR is \*(L"/\*(R". Note that \f(CW\*(C`rootdir()\*(C'\fR on Mac \s-1OS\s0 is the startup
volume, which is the closest in concept to Unix' \*(L"/\*(R". This should help
to run existing scripts originally written for Unix.
.IP "8." 2
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 \*(L"root\*(R". Generally, these cases are handled like
their Unix counterparts:
.Sp
.Vb 10
\& 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:")
.Ve
.Sp
However, this approach is limited to the first arguments following
\&\*(L"root\*(R" (again, see \f(CW\*(C`Unix\->canonpath()\*(C'\fR ). If there are more
arguments that move up the directory tree, an invalid path going
beyond root can be created.
.RE
.RS 2
.Sp
As you've seen, you can force \f(CW\*(C`catdir()\*(C'\fR to create an absolute path
by passing either an empty string or a path that begins with a volume
name as the first argument. However, you are strongly encouraged not
to do so, since this is done only for backward compatibility. Newer
versions of File::Spec come with a method called \f(CW\*(C`catpath()\*(C'\fR (see
below), that is designed to offer a portable solution for the creation
of absolute paths. It takes volume, directory and file portions and
returns an entire path. While \f(CW\*(C`catdir()\*(C'\fR is still suitable for the
concatenation of \fIdirectory names\fR, you are encouraged to use
\&\f(CW\*(C`catpath()\*(C'\fR to concatenate \fIvolume names\fR and \fIdirectory
paths\fR. E.g.
.Sp
.Vb 2
\& $dir = File::Spec->catdir("tmp","sources");
\& $abs_path = File::Spec->catpath("MacintoshHD:", $dir,"");
.Ve
.Sp
yields
.Sp
.Vb 1
\& "MacintoshHD:tmp:sources:" .
.Ve
.RE
.IP "catfile" 2
.IX Item "catfile"
Concatenate one or more directory names and a filename to form a
complete path ending with a filename. Resulting paths are \fBrelative\fR
by default, but can be forced to be absolute (but avoid this).
.Sp
\&\fB\s-1IMPORTANT\s0 \s-1NOTE:\s0\fR Beginning with version 1.3 of this module, the
resulting path is relative by default and \fInot\fR absolute. This
decision was made due to portability reasons. Since
\&\f(CW\*(C`File::Spec\->catfile()\*(C'\fR returns relative paths on all other
operating systems, it will now also follow this convention on Mac \s-1OS\s0.
Note that this may break some existing scripts.
.Sp
The last argument is always considered to be the file portion. Since
\&\f(CW\*(C`catfile()\*(C'\fR uses \f(CW\*(C`catdir()\*(C'\fR (see above) for the concatenation of the
directory portions (if any), the following with regard to relative and
absolute paths is true:
.Sp
.Vb 2
\& catfile("") = ""
\& catfile("file") = "file"
.Ve
.Sp
but
.Sp
.Vb 3
\& catfile("","") = rootdir() # (e.g. "HD:")
\& catfile("","file") = rootdir() . file # (e.g. "HD:file")
\& catfile("HD:","file") = "HD:file"
.Ve
.Sp
This means that \f(CW\*(C`catdir()\*(C'\fR is called only when there are two or more
arguments, as one might expect.
.Sp
Note that the leading \*(L":\*(R" is removed from the filename, so that
.Sp
.Vb 1
\& catfile("a","b","file") = ":a:b:file" and
.Ve
.Sp
.Vb 1
\& catfile("a","b",":file") = ":a:b:file"
.Ve
.Sp
give the same answer.
.Sp
To concatenate \fIvolume names\fR, \fIdirectory paths\fR and \fIfilenames\fR,
you are encouraged to use \f(CW\*(C`catpath()\*(C'\fR (see below).
.IP "curdir" 2
.IX Item "curdir"
Returns a string representing the current directory. On Mac \s-1OS\s0, this is \*(L":\*(R".
.IP "devnull" 2
.IX Item "devnull"
Returns a string representing the null device. On Mac \s-1OS\s0, this is \*(L"Dev:Null\*(R".
.IP "rootdir" 2
.IX Item "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 \*(L":\*(R", because that's the correct specification for a volume
name on Mac \s-1OS\s0.
.Sp
If Mac::Files could not be loaded, the empty string is returned.
.IP "tmpdir" 2
.IX Item "tmpdir"
Returns the contents of \f(CW$ENV\fR{\s-1TMPDIR\s0}, if that directory exits or the
current working directory otherwise. Under MacPerl, \f(CW$ENV\fR{\s-1TMPDIR\s0} will
contain a path like \*(L"MacintoshHD:Temporary Items:\*(R", which is a hidden
directory on your startup volume.
.IP "updir" 2
.IX Item "updir"
Returns a string representing the parent directory. On Mac \s-1OS\s0, this is \*(L"::\*(R".
.IP "file_name_is_absolute" 2
.IX Item "file_name_is_absolute"
Takes as argument a path and returns true, if it is an absolute path.
If the path has a leading \*(L":\*(R", 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 \*(L"a\*(R". In this particular case, the path is considered to be relative
(i.e. it is considered to be a filename). Use \*(L":\*(R" 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.
.Sp
E.g.
.Sp
.Vb 4
\& 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)
.Ve
.IP "path" 2
.IX Item "path"
Returns the null list for the MacPerl application, since the concept is
usually meaningless under Mac \s-1OS\s0. But if you're using the MacPerl tool under
\&\s-1MPW\s0, it gives back \f(CW$ENV\fR{Commands} suitably split, as is done in
:lib:ExtUtils:MM_Mac.pm.
.IP "splitpath" 2
.IX Item "splitpath"
.Vb 2
\& ($volume,$directories,$file) = File::Spec->splitpath( $path );
\& ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file );
.Ve
.Sp
Splits a path into volume, directory, and filename portions.
.Sp
On Mac \s-1OS\s0, assumes that the last part of the path is a filename unless
\&\f(CW$no_file\fR is true or a trailing separator \*(L":\*(R" is present.
.Sp
The volume portion is always returned with a trailing \*(L":\*(R". The directory portion
is always returned with a leading (to denote a relative path) and a trailing \*(L":\*(R"
(to denote a directory). The file portion is always returned \fIwithout\fR a leading \*(L":\*(R".
Empty portions are returned as empty string ''.
.Sp
The results can be passed to \f(CW\*(C`catpath()\*(C'\fR to get back a path equivalent to
(usually identical to) the original path.
.IP "splitdir" 2
.IX Item "splitdir"
The opposite of \f(CW\*(C`catdir()\*(C'\fR.
.Sp
.Vb 1
\& @dirs = File::Spec->splitdir( $directories );
.Ve
.Sp
$directories should be only the directory portion of the path on systems
that have the concept of a volume or that have path syntax that differentiates
files from directories. Consider using \f(CW\*(C`splitpath()\*(C'\fR otherwise.
.Sp
Unlike just splitting the directories on the separator, empty directory names
(\f(CW""\fR) can be returned. Since \f(CW\*(C`catdir()\*(C'\fR on Mac \s-1OS\s0 always appends a trailing
colon to distinguish a directory path from a file path, a single trailing colon
will be ignored, i.e. there's no empty directory name after it.
.Sp
Hence, on Mac \s-1OS\s0, both
.Sp
.Vb 2
\& File::Spec->splitdir( ":a:b::c:" ); and
\& File::Spec->splitdir( ":a:b::c" );
.Ve
.Sp
yield:
.Sp
.Vb 1
\& ( "a", "b", "::", "c")
.Ve
.Sp
while
.Sp
.Vb 1
\& File::Spec->splitdir( ":a:b::c::" );
.Ve
.Sp
yields:
.Sp
.Vb 1
\& ( "a", "b", "::", "c", "::")
.Ve
.IP "catpath" 2
.IX Item "catpath"
.Vb 1
\& $path = File::Spec->catpath($volume,$directory,$file);
.Ve
.Sp
Takes volume, directory and file portions and returns an entire path. On Mac \s-1OS\s0,
\&\f(CW$volume\fR, \f(CW$directory\fR and \f(CW$file\fR are concatenated. A ':' is inserted if need be. You
may pass an empty string for each portion. If all portions are empty, the empty
string is returned. If \f(CW$volume\fR is empty, the result will be a relative path,
beginning with a ':'. If \f(CW$volume\fR and \f(CW$directory\fR are empty, a leading \*(L":\*(R" (if any)
is removed form \f(CW$file\fR and the remainder is returned. If \f(CW$file\fR is empty, the
resulting path will have a trailing ':'.
.IP "abs2rel" 2
.IX Item "abs2rel"
Takes a destination path and an optional base path and returns a relative path
from the base path to the destination path:
.Sp
.Vb 2
\& $rel_path = File::Spec->abs2rel( $path ) ;
\& $rel_path = File::Spec->abs2rel( $path, $base ) ;
.Ve
.Sp
Note that both paths are assumed to have a notation that distinguishes a
directory path (with trailing ':') from a file path (without trailing ':').
.Sp
If \f(CW$base\fR is not present or '', then the current working directory is used.
If \f(CW$base\fR is relative, then it is converted to absolute form using \f(CW\*(C`rel2abs()\*(C'\fR.
This means that it is taken to be relative to the current working directory.
.Sp
If \f(CW$path\fR and \f(CW$base\fR appear to be on two different volumes, we will not
attempt to resolve the two paths, and we will instead simply return
\&\f(CW$path\fR. Note that previous versions of this module ignored the volume
of \f(CW$base\fR, which resulted in garbage results part of the time.
.Sp
If \f(CW$base\fR doesn't have a trailing colon, the last element of \f(CW$base\fR is
assumed to be a filename. This filename is ignored. Otherwise all path
components are assumed to be directories.
.Sp
If \f(CW$path\fR is relative, it is converted to absolute form using \f(CW\*(C`rel2abs()\*(C'\fR.
This means that it is taken to be relative to the current working directory.
.Sp
Based on code written by Shigio Yamaguchi.
.IP "rel2abs" 2
.IX Item "rel2abs"
Converts a relative path to an absolute path:
.Sp
.Vb 2
\& $abs_path = File::Spec->rel2abs( $path ) ;
\& $abs_path = File::Spec->rel2abs( $path, $base ) ;
.Ve
.Sp
Note that both paths are assumed to have a notation that distinguishes a
directory path (with trailing ':') from a file path (without trailing ':').
.Sp
If \f(CW$base\fR is not present or '', then \f(CW$base\fR is set to the current working
directory. If \f(CW$base\fR is relative, then it is converted to absolute form
using \f(CW\*(C`rel2abs()\*(C'\fR. This means that it is taken to be relative to the
current working directory.
.Sp
If \f(CW$base\fR doesn't have a trailing colon, the last element of \f(CW$base\fR is
assumed to be a filename. This filename is ignored. Otherwise all path
components are assumed to be directories.
.Sp
If \f(CW$path\fR is already absolute, it is returned and \f(CW$base\fR is ignored.
.Sp
Based on code written by Shigio Yamaguchi.
.SH "AUTHORS"
.IX Header "AUTHORS"
See the authors list in \fIFile::Spec\fR. Mac \s-1OS\s0 support by Paul Schinder
<schinder@pobox.com> and Thomas Wegner <wegner_thomas@yahoo.com>.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (c) 2004 by the Perl 5 Porters. All rights reserved.
.PP
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
See File::Spec and File::Spec::Unix. This package overrides the
implementation of these methods, not the semantics.