Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / Cwd.html
blob9085df32240ace23da79b650d28fecc36172ce39
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>Cwd - get pathname of current working directory</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;Cwd - get pathname of current working directory</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <ul>
27 <li><a href="#getcwd_and_friends">getcwd and friends</a></li>
28 <li><a href="#abs_path_and_friends">abs_path and friends</a></li>
29 <li><a href="#_env_pwd_">$ENV{PWD}</a></li>
30 </ul>
32 <li><a href="#notes">NOTES</a></li>
33 <li><a href="#author">AUTHOR</a></li>
34 <li><a href="#copyright">COPYRIGHT</a></li>
35 <li><a href="#see_also">SEE ALSO</a></li>
36 </ul>
37 <!-- INDEX END -->
39 <hr />
40 <p>
41 </p>
42 <h1><a name="name">NAME</a></h1>
43 <p>Cwd - get pathname of current working directory</p>
44 <p>
45 </p>
46 <hr />
47 <h1><a name="synopsis">SYNOPSIS</a></h1>
48 <pre>
49 use Cwd;
50 my $dir = getcwd;</pre>
51 <pre>
52 use Cwd 'abs_path';
53 my $abs_path = abs_path($file);</pre>
54 <p>
55 </p>
56 <hr />
57 <h1><a name="description">DESCRIPTION</a></h1>
58 <p>This module provides functions for determining the pathname of the
59 current working directory. It is recommended that getcwd (or another
60 *cwd() function) be used in <em>all</em> code to ensure portability.</p>
61 <p>By default, it exports the functions cwd(), getcwd(), fastcwd(), and
62 <a href="#item_fastgetcwd"><code>fastgetcwd()</code></a> (and, on Win32, <a href="#item_getdcwd"><code>getdcwd())</code></a> into the caller's namespace.</p>
63 <p>
64 </p>
65 <h2><a name="getcwd_and_friends">getcwd and friends</a></h2>
66 <p>Each of these functions are called without arguments and return the
67 absolute path of the current working directory.</p>
68 <dl>
69 <dt><strong><a name="item_getcwd">getcwd</a></strong>
71 <dd>
72 <pre>
73 my $cwd = getcwd();</pre>
74 </dd>
75 <dd>
76 <p>Returns the current working directory.</p>
77 </dd>
78 <dd>
79 <p>Re-implements the <a href="#item_getcwd"><code>getcwd(3)</code></a> (or <code>getwd(3))</code> functions in Perl.</p>
80 </dd>
81 <dt><strong><a name="item_cwd">cwd</a></strong>
83 <dd>
84 <pre>
85 my $cwd = cwd();</pre>
86 </dd>
87 <dd>
88 <p>The <a href="#item_cwd"><code>cwd()</code></a> is the most natural form for the current architecture. For
89 most systems it is identical to `pwd` (but without the trailing line
90 terminator).</p>
91 </dd>
92 <dt><strong><a name="item_fastcwd">fastcwd</a></strong>
94 <dd>
95 <pre>
96 my $cwd = fastcwd();</pre>
97 </dd>
98 <dd>
99 <p>A more dangerous version of getcwd(), but potentially faster.</p>
100 </dd>
101 <dd>
102 <p>It might conceivably <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_chdir"><code>chdir()</code></a> you out of a directory that it can't
103 <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_chdir"><code>chdir()</code></a> you back into. If fastcwd encounters a problem it will return
104 undef but will probably leave you in a different directory. For a
105 measure of extra security, if everything appears to have worked, the
106 <a href="#item_fastcwd"><code>fastcwd()</code></a> function will check that it leaves you in the same directory
107 that it started in. If it has changed it will <code>die</code> with the message
108 ``Unstable directory path, current directory changed
109 unexpectedly''. That should never happen.</p>
110 </dd>
111 <dt><strong><a name="item_fastgetcwd">fastgetcwd</a></strong>
113 <dd>
114 <pre>
115 my $cwd = fastgetcwd();</pre>
116 </dd>
117 <dd>
118 <p>The <a href="#item_fastgetcwd"><code>fastgetcwd()</code></a> function is provided as a synonym for cwd().</p>
119 </dd>
120 <dt><strong><a name="item_getdcwd">getdcwd</a></strong>
122 <dd>
123 <pre>
124 my $cwd = getdcwd();
125 my $cwd = getdcwd('C:');</pre>
126 </dd>
127 <dd>
128 <p>The <a href="#item_getdcwd"><code>getdcwd()</code></a> function is also provided on Win32 to get the current working
129 directory on the specified drive, since Windows maintains a separate current
130 working directory for each drive. If no drive is specified then the current
131 drive is assumed.</p>
132 </dd>
133 <dd>
134 <p>This function simply calls the Microsoft C library <code>_getdcwd()</code> function.</p>
135 </dd>
136 </dl>
138 </p>
139 <h2><a name="abs_path_and_friends">abs_path and friends</a></h2>
140 <p>These functions are exported only on request. They each take a single
141 argument and return the absolute pathname for it. If no argument is
142 given they'll use the current working directory.</p>
143 <dl>
144 <dt><strong><a name="item_abs_path">abs_path</a></strong>
146 <dd>
147 <pre>
148 my $abs_path = abs_path($file);</pre>
149 </dd>
150 <dd>
151 <p>Uses the same algorithm as getcwd(). Symbolic links and relative-path
152 components (``.'' and ``..'') are resolved to return the canonical
153 pathname, just like realpath(3).</p>
154 </dd>
155 <dt><strong><a name="item_realpath">realpath</a></strong>
157 <dd>
158 <pre>
159 my $abs_path = realpath($file);</pre>
160 </dd>
161 <dd>
162 <p>A synonym for abs_path().</p>
163 </dd>
164 <dt><strong><a name="item_fast_abs_path">fast_abs_path</a></strong>
166 <dd>
167 <pre>
168 my $abs_path = fast_abs_path($file);</pre>
169 </dd>
170 <dd>
171 <p>A more dangerous, but potentially faster version of abs_path.</p>
172 </dd>
173 </dl>
175 </p>
176 <h2><a name="_env_pwd_">$ENV{PWD}</a></h2>
177 <p>If you ask to override your <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_chdir"><code>chdir()</code></a> built-in function,</p>
178 <pre>
179 use Cwd qw(chdir);</pre>
180 <p>then your PWD environment variable will be kept up to date. Note that
181 it will only be kept up to date if all packages which use chdir import
182 it from Cwd.</p>
184 </p>
185 <hr />
186 <h1><a name="notes">NOTES</a></h1>
187 <ul>
188 <li>
189 <p>Since the path seperators are different on some operating systems ('/'
190 on Unix, ':' on MacPerl, etc...) we recommend you use the File::Spec
191 modules wherever portability is a concern.</p>
192 </li>
193 <li>
194 <p>Actually, on Mac OS, the <a href="#item_getcwd"><code>getcwd()</code></a>, <a href="#item_fastgetcwd"><code>fastgetcwd()</code></a> and <a href="#item_fastcwd"><code>fastcwd()</code></a>
195 functions are all aliases for the <a href="#item_cwd"><code>cwd()</code></a> function, which, on Mac OS,
196 calls `pwd`. Likewise, the <a href="#item_abs_path"><code>abs_path()</code></a> function is an alias for
197 <a href="#item_fast_abs_path"><code>fast_abs_path()</code></a>.</p>
198 </li>
199 </ul>
201 </p>
202 <hr />
203 <h1><a name="author">AUTHOR</a></h1>
204 <p>Originally by the perl5-porters.</p>
205 <p>Maintained by Ken Williams &lt;<a href="mailto:KWILLIAMS@cpan.org">KWILLIAMS@cpan.org</a>&gt;</p>
207 </p>
208 <hr />
209 <h1><a name="copyright">COPYRIGHT</a></h1>
210 <p>Copyright (c) 2004 by the Perl 5 Porters. All rights reserved.</p>
211 <p>This program is free software; you can redistribute it and/or modify
212 it under the same terms as Perl itself.</p>
213 <p>Portions of the C code in this library are copyright (c) 1994 by the
214 Regents of the University of California. All rights reserved. The
215 license on this code is compatible with the licensing of the rest of
216 the distribution - please see the source code in <em>Cwd.xs</em> for the
217 details.</p>
219 </p>
220 <hr />
221 <h1><a name="see_also">SEE ALSO</a></h1>
222 <p><a href="file://C|\msysgit\mingw\html/File/chdir.html">the File::chdir manpage</a></p>
223 <table border="0" width="100%" cellspacing="0" cellpadding="3">
224 <tr><td class="block" style="background-color: #cccccc" valign="middle">
225 <big><strong><span class="block">&nbsp;Cwd - get pathname of current working directory</span></strong></big>
226 </td></tr>
227 </table>
229 </body>
231 </html>