NAME
File::Spec::Mac - File::Spec for Mac OS (Classic)
SYNOPSIS
DESCRIPTION
Methods for manipulating file specifications.
Perlbrew install perl-5.16.0 perlbrew switch perl-5.16.0 To play with the bleeding-edge version, but only in the current shell: perlbrew install perl-blead perlbrew use perl-blead Runs myprogram.pl against all installations of perl, especially helpful when running tests: perlbrew exec perl myprogram.pl For more descriptions about commands. Mar 14, 2020 Perl used to have such a subroutine, but that is no more the case. Check your shared library path, and any shared Perl libraries in those directories. Sometimes this problem may also indicate a partial Perl 5.8.0 installation, see 'Mac OS X dyld undefined symbols' for an example and how to deal with it. Self-tying Problems. Perl's developers have made a concerted effort to update Perl to be in sync with the latest Unicode standard. Changes for this include: Perl can now handle every Unicode character property. New documentation, perluniprops, lists all available non-Unihan character properties. By default, perl does not expose Unihan, deprecated or Unicode. ActiveState ActivePerl (Windows) 5.12.3.1204 free download. Get the latest version now. ActivePerl that is offered by ActiveState is the industry-standard, and available for Windows, Linux and Mac OS X. Universal developers rely on ActivePerls's completeness and ease-of-use, while business users protect their infrastructure and stay aggressive. PATCHLEVEL is now PERLVERSION. The cpp macros PERLREVISION, PERLVERSION, and PERLSUBVERSION are now available by default from perl.h, and reflect the base revision, patchlevel, and subversion respectively. PERLREVISION had no prior equivalent, while PERLVERSION and PERLSUBVERSION were previously available as PATCHLEVEL and SUBVERSION.
METHODS
- canonpathOn 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). Automaticallyputs a trailing ':' on the end of the complete path, because that's what'sdone in MacPerl's environment and helps to distinguish a file path from adirectory path.IMPORTANT NOTE: Beginning with version 1.3 of this module, the resultingpath is relative by default and not absolute. This decision was made dueto portability reasons. Since
File::Spec->catdir()
returns relative pathson all other operating systems, it will now also follow this convention on MacOS. Note that this may break some existing scripts.The intended purpose of this routine is to concatenate directory names.But because of the nature of Macintosh paths, some additional possibilitiesare allowed to make using this routine give reasonable results for somecommon situations. In other words, you are also allowed to concatenatepaths instead of directory names (strictly speaking, a string like ':a'is a path, but not a name, since it contains a punctuation character ':').So, beside calls likecalls like the followingare allowed.Here are the rules that are used incatdir()
; note that we try to be ascompatible as possible to Unix: - The resulting path is relative by default, i.e. the resulting path will have aleading colon.
- A trailing colon is added automatically to the resulting path, to denote adirectory.
- Generally, each argument has one leading ':' and one trailing ':'removed (if any). They are then joined together by a ':'. Specialtreatment applies for arguments denoting updir paths like '::lib:',see (4), or arguments consisting solely of colons ('colon paths'),see (5).
- When an updir path like ':::lib::' is passed as argument, the numberof directories to climb up is handled correctly, not removing leadingor trailing colons when necessary. E.g.
- Adding a colon ':' or empty string ' to a path at any positiondoesn'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 (seecanonpath() in File::Spec::Unix ). Likewise, a '::' is handled like a '..'(updir), and a ':::' is handled like a '../..' etc. E.g.
- If the first argument is an empty string ' or is a volume name, i.e. matchesthe pattern /^[^:]+:/, the resulting path is absolute.
- Passing an empty string ' as the first argument to
catdir()
islike passingFile::Spec->rootdir()
as the first argument, i.e.This is true on Unix, wherecatdir(','a','b')
yields '/a/b' androotdir()
is '/'. Note thatrootdir()
on Mac OS is the startupvolume, which is the closest in concept to Unix' '/'. This should helpto run existing scripts originally written for Unix. - For absolute paths, some cleanup is done, to ensure that the volumename isn't immediately followed by updirs. This is invalid, becausethis would go beyond 'root'. Generally, these cases are handled liketheir Unix counterparts:However, this approach is limited to the first arguments following'root' (again, see canonpath() in File::Spec::Unix. If there are morearguments that move up the directory tree, an invalid path goingbeyond root can be created.
- catfileConcatenate one or more directory names and a filename to form acomplete path ending with a filename. Resulting paths are relativeby default, but can be forced to be absolute (but avoid this).IMPORTANT NOTE: Beginning with version 1.3 of this module, theresulting path is relative by default and not absolute. Thisdecision was made due to portability reasons. Since
File::Spec->catfile()
returns relative paths on all otheroperating systems, it will now also follow this convention on Mac OS.Note that this may break some existing scripts.The last argument is always considered to be the file portion. Sincecatfile()
usescatdir()
(see above) for the concatenation of thedirectory portions (if any), the following with regard to relative andabsolute paths is true:butThis means thatcatdir()
is called only when there are two or morearguments, as one might expect.Note that the leading ':' is removed from the filename, so thatgive the same answer.To concatenate volume names, directory paths and filenames,you are encouraged to usecatpath()
(see below). - curdirReturns a string representing the current directory. On Mac OS, this is ':'.
- devnullReturns a string representing the null device. On Mac OS, this is 'Dev:Null'.
- rootdirReturns the empty string. Mac OS has no real root directory.
- tmpdirReturns the contents of $ENV{TMPDIR}, if that directory exits or thecurrent working directory otherwise. Under MacPerl, $ENV{TMPDIR} willcontain a path like 'MacintoshHD:Temporary Items:', which is a hiddendirectory on your startup volume.
- updirReturns a string representing the parent directory. On Mac OS, this is '::'.
- file_name_is_absoluteTakes 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 anabsolute path, unless the path doesn't contain any colons, i.e. it's a namelike '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 placein the path if you want to distinguish unambiguously. As a special case,the filename ' is always considered to be absolute. Note that with version1.2 of File::Spec::Mac, this does no longer consult the local filesystem.E.g.
- pathReturns the null list for the MacPerl application, since the concept isusually meaningless under Mac OS. But if you're using the MacPerl tool underMPW, it gives back $ENV{Commands} suitably split, as is done in:lib:ExtUtils:MM_Mac.pm.
- splitpathSplits a path into volume, directory, and filename portions.On Mac OS, assumes that the last part of the path is a filename unless$no_file is true or a trailing separator ':' is present.The volume portion is always returned with a trailing ':'. The directory portionis always returned with a leading (to denote a relative path) and a trailing ':'(to denote a directory). The file portion is always returned without a leading ':'.Empty portions are returned as empty string '.The results can be passed to
catpath()
to get back a path equivalent to(usually identical to) the original path. - splitdirThe opposite of
catdir()
.$directories should be only the directory portion of the path on systemsthat have the concept of a volume or that have path syntax that differentiatesfiles from directories. Consider usingsplitpath()
otherwise.Unlike just splitting the directories on the separator, empty directory names('
) can be returned. Sincecatdir()
on Mac OS always appends a trailingcolon to distinguish a directory path from a file path, a single trailing colonwill be ignored, i.e. there's no empty directory name after it.Hence, on Mac OS, bothyield:whileyields: - catpathTakes volume, directory and file portions and returns an entire path. On Mac OS,$volume, $directory and $file are concatenated. A ':' is inserted if need be. Youmay pass an empty string for each portion. If all portions are empty, the emptystring is returned. If $volume is empty, the result will be a relative path,beginning with a ':'. If $volume and $directory are empty, a leading ':' (if any)is removed form $file and the remainder is returned. If $file is empty, theresulting path will have a trailing ':'.
- abs2relTakes a destination path and an optional base path and returns a relative pathfrom the base path to the destination path:Note that both paths are assumed to have a notation that distinguishes adirectory path (with trailing ':') from a file path (without trailing ':').If $base is not present or ', then the current working directory is used.If $base is relative, then it is converted to absolute form using
rel2abs()
.This means that it is taken to be relative to the current working directory.If $path and $base appear to be on two different volumes, we will notattempt to resolve the two paths, and we will instead simply return$path. Note that previous versions of this module ignored the volumeof $base, which resulted in garbage results part of the time.If $base doesn't have a trailing colon, the last element of $base isassumed to be a filename. This filename is ignored. Otherwise all pathcomponents are assumed to be directories.If $path is relative, it is converted to absolute form usingrel2abs()
.This means that it is taken to be relative to the current working directory.Based on code written by Shigio Yamaguchi. - rel2absConverts a relative path to an absolute path:Note that both paths are assumed to have a notation that distinguishes adirectory path (with trailing ':') from a file path (without trailing ':').If $base is not present or ', then $base is set to the current workingdirectory. If $base is relative, then it is converted to absolute formusing
rel2abs()
. This means that it is taken to be relative to thecurrent working directory.If $base doesn't have a trailing colon, the last element of $base isassumed to be a filename. This filename is ignored. Otherwise all pathcomponents are assumed to be directories.If $path is already absolute, it is returned and $base is ignored.Based on code written by Shigio Yamaguchi.
As you've seen, you can force
catdir()
to create an absolute pathby passing either an empty string or a path that begins with a volumename as the first argument. However, you are strongly encouraged notto do so, since this is done only for backward compatibility. Newerversions of File::Spec come with a method called catpath()
(seebelow), that is designed to offer a portable solution for the creationof absolute paths. It takes volume, directory and file portions andreturns an entire path. While catdir()
is still suitable for theconcatenation of directory names, you are encouraged to usecatpath()
to concatenate volume names and directorypaths. E.g.yields
AUTHORS
See the authors list in File::Spec. Mac OS support by Paul Schinder<[email protected]> and Thomas Wegner <[email protected]>.
COPYRIGHT
Copyright (c) 2004 by the Perl 5 Porters. All rights reserved.
This program is free software; you can redistribute it and/or modifyit under the same terms as Perl itself.
![Perlcc For Perl 5.12.3 For Mac Perlcc For Perl 5.12.3 For Mac](/uploads/1/1/8/0/118041928/765606572.png)
SEE ALSO
Cached
See File::Spec and File::Spec::Unix. This package overrides theimplementation of these methods, not the semantics.