spec.html

来自「perl教程」· HTML 代码 · 共 443 行 · 第 1/2 页

HTML
443
字号
    <span class="variable">$is_case_tolerant</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">case_tolerant</span><span class="operator">();</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_file_name_is_absolute">file_name_is_absolute</a></strong>

<dd>
<p>Takes as its argument a path, and returns true if it is an absolute path.</p>
</dd>
<dd>
<pre>
    <span class="variable">$is_absolute</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">file_name_is_absolute</span><span class="operator">(</span> <span class="variable">$path</span> <span class="operator">);</span>
</pre>
</dd>
<dd>
<p>This does not consult the local filesystem on Unix, Win32, OS/2, or
Mac OS (Classic).  It does consult the working environment for VMS
(see <a href="../../lib/File/Spec/VMS.html#file_name_is_absolute">file_name_is_absolute in the File::Spec::VMS manpage</a>).</p>
</dd>
</li>
<dt><strong><a name="item_path">path</a></strong>

<dd>
<p>Takes no argument.  Returns the environment variable <a href="../../lib/Pod/perlrun.html#item_path"><code>PATH</code></a> (or the local
platform's equivalent) as a list.</p>
</dd>
<dd>
<pre>
    <span class="variable">@PATH</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">path</span><span class="operator">();</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_join">join</a></strong>

<dd>
<p>join is the same as catfile.</p>
</dd>
</li>
<dt><strong><a name="item_splitpath">splitpath</a></strong>

<dd>
<p>Splits a path in to volume, directory, and filename portions. On systems
with no concept of volume, returns '' for volume.</p>
</dd>
<dd>
<pre>
    <span class="operator">(</span><span class="variable">$volume</span><span class="operator">,</span><span class="variable">$directories</span><span class="operator">,</span><span class="variable">$file</span><span class="operator">)</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">splitpath</span><span class="operator">(</span> <span class="variable">$path</span> <span class="operator">);</span>
    <span class="operator">(</span><span class="variable">$volume</span><span class="operator">,</span><span class="variable">$directories</span><span class="operator">,</span><span class="variable">$file</span><span class="operator">)</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">splitpath</span><span class="operator">(</span> <span class="variable">$path</span><span class="operator">,</span> <span class="variable">$no_file</span> <span class="operator">);</span>
</pre>
</dd>
<dd>
<p>For systems with no syntax differentiating filenames from directories, 
assumes that the last file is a path unless <code>$no_file</code> is true or a
trailing separator or <em>/.</em> or <em>/..</em> is present. On Unix, this means that <code>$no_file</code>
true makes this return ( '', $path, '' ).</p>
</dd>
<dd>
<p>The directory portion may or may not be returned with a trailing '/'.</p>
</dd>
<dd>
<p>The results can be passed to <a href="#item_catpath">catpath()</a> to get back a path equivalent to
(usually identical to) the original path.</p>
</dd>
</li>
<dt><strong><a name="item_splitdir">splitdir</a></strong>

<dd>
<p>The opposite of <a href="#item_catdir">catdir()</a>.</p>
</dd>
<dd>
<pre>
    <span class="variable">@dirs</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">splitdir</span><span class="operator">(</span> <span class="variable">$directories</span> <span class="operator">);</span>
</pre>
</dd>
<dd>
<p><code>$directories</code> must 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.</p>
</dd>
<dd>
<p>Unlike just splitting the directories on the separator, empty
directory names (<code>''</code>) can be returned, because these are significant
on some OSes.</p>
</dd>
</li>
<dt><strong><a name="item_catpath"><code>catpath()</code></a></strong>

<dd>
<p>Takes volume, directory and file portions and returns an entire path. Under
Unix, <code>$volume</code> is ignored, and directory and file are concatenated.  A '/' is
inserted if need be.  On other OSes, <code>$volume</code> is significant.</p>
</dd>
<dd>
<pre>
    <span class="variable">$full_path</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">catpath</span><span class="operator">(</span> <span class="variable">$volume</span><span class="operator">,</span> <span class="variable">$directory</span><span class="operator">,</span> <span class="variable">$file</span> <span class="operator">);</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_abs2rel">abs2rel</a></strong>

<dd>
<p>Takes a destination path and an optional base path returns a relative path
from the base path to the destination path:</p>
</dd>
<dd>
<pre>
    <span class="variable">$rel_path</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">abs2rel</span><span class="operator">(</span> <span class="variable">$path</span> <span class="operator">)</span> <span class="operator">;</span>
    <span class="variable">$rel_path</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">abs2rel</span><span class="operator">(</span> <span class="variable">$path</span><span class="operator">,</span> <span class="variable">$base</span> <span class="operator">)</span> <span class="operator">;</span>
</pre>
</dd>
<dd>
<p>If <code>$base</code> is not present or '', then <a href="../../lib/Cwd.html">cwd()</a> is used. If <code>$base</code> is
relative, then it is converted to absolute form using
<a href="#item_rel2abs">rel2abs()</a>. This means that it is taken to be relative to
<a href="../../lib/Cwd.html">cwd()</a>.</p>
</dd>
<dd>
<p>On systems with the concept of volume, if <code>$path</code> and <code>$base</code> appear to be
on two different volumes, we will not attempt to resolve the two
paths, and we will instead simply return <code>$path</code>.  Note that previous
versions of this module ignored the volume of <code>$base</code>, which resulted in
garbage results part of the time.</p>
</dd>
<dd>
<p>On systems that have a grammar that indicates filenames, this ignores the 
<code>$base</code> filename as well. Otherwise all path components are assumed to be
directories.</p>
</dd>
<dd>
<p>If <code>$path</code> is relative, it is converted to absolute form using <a href="#item_rel2abs">rel2abs()</a>.
This means that it is taken to be relative to <a href="../../lib/Cwd.html">cwd()</a>.</p>
</dd>
<dd>
<p>No checks against the filesystem are made.  On VMS, there is
interaction with the working environment, as logicals and
macros are expanded.</p>
</dd>
<dd>
<p>Based on code written by Shigio Yamaguchi.</p>
</dd>
</li>
<dt><strong><a name="item_rel2abs"><code>rel2abs()</code></a></strong>

<dd>
<p>Converts a relative path to an absolute path.</p>
</dd>
<dd>
<pre>
    <span class="variable">$abs_path</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">rel2abs</span><span class="operator">(</span> <span class="variable">$path</span> <span class="operator">)</span> <span class="operator">;</span>
    <span class="variable">$abs_path</span> <span class="operator">=</span> <span class="variable">File::Spec</span><span class="operator">-&gt;</span><span class="variable">rel2abs</span><span class="operator">(</span> <span class="variable">$path</span><span class="operator">,</span> <span class="variable">$base</span> <span class="operator">)</span> <span class="operator">;</span>
</pre>
</dd>
<dd>
<p>If <code>$base</code> is not present or '', then <a href="../../lib/Cwd.html">cwd()</a> is used. If <code>$base</code> is relative,
then it is converted to absolute form using <a href="#item_rel2abs">rel2abs()</a>. This means that it
is taken to be relative to <a href="../../lib/Cwd.html">cwd()</a>.</p>
</dd>
<dd>
<p>On systems with the concept of volume, if <code>$path</code> and <code>$base</code> appear to be
on two different volumes, we will not attempt to resolve the two
paths, and we will instead simply return <code>$path</code>.  Note that previous
versions of this module ignored the volume of <code>$base</code>, which resulted in
garbage results part of the time.</p>
</dd>
<dd>
<p>On systems that have a grammar that indicates filenames, this ignores the 
<code>$base</code> filename as well. Otherwise all path components are assumed to be
directories.</p>
</dd>
<dd>
<p>If <code>$path</code> is absolute, it is cleaned up and returned using <a href="#item_canonpath">canonpath()</a>.</p>
</dd>
<dd>
<p>No checks against the filesystem are made.  On VMS, there is
interaction with the working environment, as logicals and
macros are expanded.</p>
</dd>
<dd>
<p>Based on code written by Shigio Yamaguchi.</p>
</dd>
</li>
</dl>
<p>For further information, please see <a href="../../lib/File/Spec/Unix.html">the File::Spec::Unix manpage</a>,
<a href="../../lib/File/Spec/Mac.html">the File::Spec::Mac manpage</a>, <a href="../../lib/File/Spec/OS2.html">the File::Spec::OS2 manpage</a>, <a href="../../lib/File/Spec/Win32.html">the File::Spec::Win32 manpage</a>, or
<a href="../../lib/File/Spec/VMS.html">the File::Spec::VMS manpage</a>.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/File/Spec/Unix.html">the File::Spec::Unix manpage</a>, <a href="../../lib/File/Spec/Mac.html">the File::Spec::Mac manpage</a>, <a href="../../lib/File/Spec/OS2.html">the File::Spec::OS2 manpage</a>,
<a href="../../lib/File/Spec/Win32.html">the File::Spec::Win32 manpage</a>, <a href="../../lib/File/Spec/VMS.html">the File::Spec::VMS manpage</a>, <a href="../../lib/File/Spec/Functions.html">the File::Spec::Functions manpage</a>,
<a href="../../lib/ExtUtils/MakeMaker.html">the ExtUtils::MakeMaker manpage</a></p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Currently maintained by Ken Williams <code>&lt;KWILLIAMS@cpan.org&gt;</code>.</p>
<p>The vast majority of the code was written by
Kenneth Albanowski <code>&lt;kjahds@kjahds.com&gt;</code>,
Andy Dougherty <code>&lt;doughera@lafayette.edu&gt;</code>,
Andreas K&ouml;nig <code>&lt;A.Koenig@franz.ww.TU-Berlin.DE&gt;</code>,
Tim Bunce <code>&lt;Tim.Bunce@ig.co.uk&gt;</code>.
VMS support by Charles Bailey <code>&lt;bailey@newman.upenn.edu&gt;</code>.
OS/2 support by Ilya Zakharevich <code>&lt;ilya@math.ohio-state.edu&gt;</code>.
Mac support by Paul Schinder <code>&lt;schinder@pobox.com&gt;</code>, and
Thomas Wegner <code>&lt;wegner_thomas@yahoo.com&gt;</code>.
<a href="#item_abs2rel"><code>abs2rel()</code></a> and <a href="#item_rel2abs"><code>rel2abs()</code></a> written by Shigio Yamaguchi <code>&lt;shigio@tamacom.com&gt;</code>,
modified by Barrie Slaymaker <code>&lt;barries@slaysys.com&gt;</code>.
splitpath(), splitdir(), <a href="#item_catpath"><code>catpath()</code></a> and <a href="#item_catdir"><code>catdir()</code></a> by Barrie Slaymaker.</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 2004 by the Perl 5 Porters.  All rights reserved.</p>
<p>This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.</p>

</body>

</html>

⌨️ 快捷键说明

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