⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file::spec::mac.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
.SpHowever, this approach is limited to the first arguments following\&\*(L"root\*(R" (again, see \f(CW\*(C`Unix\->canonpath()\*(C'\fR ). If there are morearguments that move up the directory tree, an invalid path goingbeyond root can be created..RE.RS 2.SpAs you've seen, you can force \f(CW\*(C`catdir()\*(C'\fR 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 \f(CW\*(C`catpath()\*(C'\fR (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 \f(CW\*(C`catdir()\*(C'\fR is still suitable for theconcatenation of \fIdirectory names\fR, you are encouraged to use\&\f(CW\*(C`catpath()\*(C'\fR to concatenate \fIvolume names\fR and \fIdirectorypaths\fR. E.g..Sp.Vb 2\&    $dir      = File::Spec\->catdir("tmp","sources");\&    $abs_path = File::Spec\->catpath("MacintoshHD:", $dir,"");.Ve.Spyields.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 acomplete path ending with a filename. Resulting paths are \fBrelative\fRby 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, theresulting path is relative by default and \fInot\fR absolute. Thisdecision was made due to portability reasons. Since\&\f(CW\*(C`File::Spec\->catfile()\*(C'\fR returns relative paths on all otheroperating systems, it will now also follow this convention on Mac \s-1OS\s0.Note that this may break some existing scripts..SpThe 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 thedirectory portions (if any), the following with regard to relative andabsolute paths is true:.Sp.Vb 2\&    catfile("")     = ""\&    catfile("file") = "file".Ve.Spbut.Sp.Vb 3\&    catfile("","")        = rootdir()         # (e.g. "HD:")\&    catfile("","file")    = rootdir() . file  # (e.g. "HD:file")\&    catfile("HD:","file") = "HD:file".Ve.SpThis means that \f(CW\*(C`catdir()\*(C'\fR is called only when there are two or morearguments, as one might expect..SpNote that the leading \*(L":\*(R" is removed from the filename, so that.Sp.Vb 1\&    catfile("a","b","file")  = ":a:b:file"    and\&\&    catfile("a","b",":file") = ":a:b:file".Ve.Spgive the same answer..SpTo 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 inconcept, although other volumes aren't rooted there. The name has atrailing \*(L":\*(R", because that's the correct specification for a volumename on Mac \s-1OS\s0..SpIf 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 thecurrent working directory otherwise. Under MacPerl, \f(CW$ENV\fR{\s-1TMPDIR\s0} willcontain a path like \*(L"MacintoshHD:Temporary Items:\*(R", which is a hiddendirectory 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 anabsolute path, unless the path doesn't contain any colons, i.e. it's a namelike \*(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 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..SpE.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 isusually 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.SpSplits a path into volume, directory, and filename portions..SpOn 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..SpThe volume portion is always returned with a trailing \*(L":\*(R". The directory portionis 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 ''..SpThe 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\&\f(CW$directories\fR 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 using \f(CW\*(C`splitpath()\*(C'\fR otherwise..SpUnlike 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 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..SpHence, on Mac \s-1OS\s0, both.Sp.Vb 2\&    File::Spec\->splitdir( ":a:b::c:" );    and\&    File::Spec\->splitdir( ":a:b::c" );.Ve.Spyield:.Sp.Vb 1\&    ( "a", "b", "::", "c").Ve.Spwhile.Sp.Vb 1\&    File::Spec\->splitdir( ":a:b::c::" );.Ve.Spyields:.Sp.Vb 1\&    ( "a", "b", "::", "c", "::").Ve.IP "catpath" 2.IX Item "catpath".Vb 1\&    $path = File::Spec\->catpath($volume,$directory,$file);.Ve.SpTakes 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. Youmay pass an empty string for each portion. If all portions are empty, the emptystring 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, theresulting path will have a trailing ':'..IP "abs2rel" 2.IX Item "abs2rel"Takes a destination path and an optional base path and returns a relative pathfrom the base path to the destination path:.Sp.Vb 2\&    $rel_path = File::Spec\->abs2rel( $path ) ;\&    $rel_path = File::Spec\->abs2rel( $path, $base ) ;.Ve.SpNote that both paths are assumed to have a notation that distinguishes adirectory path (with trailing ':') from a file path (without trailing ':')..SpIf \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..SpIf \f(CW$path\fR and \f(CW$base\fR appear to be on two different volumes, we will notattempt to resolve the two paths, and we will instead simply return\&\f(CW$path\fR.  Note that previous versions of this module ignored the volumeof \f(CW$base\fR, which resulted in garbage results part of the time..SpIf \f(CW$base\fR doesn't have a trailing colon, the last element of \f(CW$base\fR isassumed to be a filename.  This filename is ignored.  Otherwise all pathcomponents are assumed to be directories..SpIf \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..SpBased 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.SpNote that both paths are assumed to have a notation that distinguishes adirectory path (with trailing ':') from a file path (without trailing ':')..SpIf \f(CW$base\fR is not present or '', then \f(CW$base\fR is set to the current workingdirectory. If \f(CW$base\fR is relative, then it is converted to absolute formusing \f(CW\*(C`rel2abs()\*(C'\fR. This means that it is taken to be relative to thecurrent working directory..SpIf \f(CW$base\fR doesn't have a trailing colon, the last element of \f(CW$base\fR isassumed to be a filename.  This filename is ignored.  Otherwise all pathcomponents are assumed to be directories..SpIf \f(CW$path\fR is already absolute, it is returned and \f(CW$base\fR is ignored..SpBased 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..PPThis program is free software; you can redistribute it and/or modifyit under the same terms as Perl itself..SH "SEE ALSO".IX Header "SEE ALSO"See File::Spec and File::Spec::Unix.  This package overrides theimplementation of these methods, not the semantics.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -