Debian Codegraph @

upstream/debian-unstable/man3/File::Spec::Unix.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "File::Spec::Unix 3perl"
58 .TH File::Spec::Unix 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 File::Spec::Unix \- File::Spec for Unix, base for other File::Spec modules
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 1
68 \& require File::Spec::Unix; # Done automatically by File::Spec
69 .Ve
70 .SH DESCRIPTION
71 .IX Header "DESCRIPTION"
72 Methods for manipulating file specifications. Other File::Spec
73 modules, such as File::Spec::Mac, inherit from File::Spec::Unix and
74 override specific methods.
75 .SH METHODS
76 .IX Header "METHODS"
77 .IP \fBcanonpath()\fR 2
78 .IX Item "canonpath()"
79 No physical check on the filesystem, but a logical cleanup of a
80 path. On UNIX eliminates successive slashes and successive "/.".
81 .Sp
82 .Vb 1
83 \& $cpath = File::Spec\->canonpath( $path ) ;
84 .Ve
85 .Sp
86 Note that this does *not* collapse \fIx/../y\fR sections into \fIy\fR. This
87 is by design. If \fI/foo\fR on your system is a symlink to \fI/bar/baz\fR,
88 then \fI/foo/../quux\fR is actually \fI/bar/quux\fR, not \fI/quux\fR as a naive
89 \&\fI../\fR\-removal would give you. If you want to do this kind of
90 processing, you probably want \f(CW\*(C`Cwd\*(C'\fR's \f(CWrealpath()\fR function to
91 actually traverse the filesystem cleaning up paths like this.
92 .IP \fBcatdir()\fR 2
93 .IX Item "catdir()"
94 Concatenate two or more directory names to form a complete path ending
95 with a directory. But remove the trailing slash from the resulting
96 string, because it doesn't look good, isn't necessary and confuses
97 OS2. Of course, if this is the root directory, don't cut off the
98 trailing slash :\-)
99 .IP catfile 2
100 .IX Item "catfile"
101 Concatenate one or more directory names and a filename to form a
102 complete path ending with a filename
103 .IP curdir 2
104 .IX Item "curdir"
105 Returns a string representation of the current directory. "." on UNIX.
106 .IP devnull 2
107 .IX Item "devnull"
108 Returns a string representation of the null device. "/dev/null" on UNIX.
109 .IP rootdir 2
110 .IX Item "rootdir"
111 Returns a string representation of the root directory. "/" on UNIX.
112 .IP tmpdir 2
113 .IX Item "tmpdir"
114 Returns a string representation of the first writable directory from
115 the following list or the current directory if none from the list are
116 writable:
117 .Sp
118 .Vb 2
119 \& $ENV{TMPDIR}
120 \& /tmp
121 .Ve
122 .Sp
123 If running under taint mode, and if \f(CW$ENV\fR{TMPDIR}
124 is tainted, it is not used.
125 .IP updir 2
126 .IX Item "updir"
127 Returns a string representation of the parent directory. ".." on UNIX.
128 .IP no_upwards 2
129 .IX Item "no_upwards"
130 Given a list of file names, strip out those that refer to a parent
131 directory. (Does not strip symlinks, only '.', '..', and equivalents.)
132 .IP case_tolerant 2
133 .IX Item "case_tolerant"
134 Returns a true or false value indicating, respectively, that alphabetic
135 is not or is significant when comparing file specifications.
136 .IP file_name_is_absolute 2
137 .IX Item "file_name_is_absolute"
138 Takes as argument a path and returns true if it is an absolute path.
139 .Sp
140 This does not consult the local filesystem on Unix, Win32, OS/2 or Mac
141 OS (Classic). It does consult the working environment for VMS (see
142 "file_name_is_absolute" in File::Spec::VMS).
143 .IP path 2
144 .IX Item "path"
145 Takes no argument, returns the environment variable PATH as an array.
146 .IP join 2
147 .IX Item "join"
148 join is the same as catfile.
149 .IP splitpath 2
150 .IX Item "splitpath"
151 .Vb 3
152 \& ($volume,$directories,$file) = File::Spec\->splitpath( $path );
153 \& ($volume,$directories,$file) = File::Spec\->splitpath( $path,
154 \& $no_file );
155 .Ve
156 .Sp
157 Splits a path into volume, directory, and filename portions. On systems
158 with no concept of volume, returns '' for volume.
159 .Sp
160 For systems with no syntax differentiating filenames from directories,
161 assumes that the last file is a path unless \f(CW$no_file\fR is true or a
162 trailing separator or /. or /.. is present. On Unix this means that \f(CW$no_file\fR
163 true makes this return ( '', \f(CW$path\fR, '' ).
164 .Sp
165 The directory portion may or may not be returned with a trailing '/'.
166 .Sp
167 The results can be passed to "\fBcatpath()\fR" to get back a path equivalent to
168 (usually identical to) the original path.
169 .IP splitdir 2
170 .IX Item "splitdir"
171 The opposite of "\fBcatdir()\fR".
172 .Sp
173 .Vb 1
174 \& @dirs = File::Spec\->splitdir( $directories );
175 .Ve
176 .Sp
177 \&\f(CW$directories\fR must be only the directory portion of the path on systems
178 that have the concept of a volume or that have path syntax that differentiates
179 files from directories.
180 .Sp
181 Unlike just splitting the directories on the separator, empty
182 directory names (\f(CW\*(Aq\*(Aq\fR) can be returned, because these are significant
183 on some OSs.
184 .Sp
185 On Unix,
186 .Sp
187 .Vb 1
188 \& File::Spec\->splitdir( "/a/b//c/" );
189 .Ve
190 .Sp
191 Yields:
192 .Sp
193 .Vb 1
194 \& ( \*(Aq\*(Aq, \*(Aqa\*(Aq, \*(Aqb\*(Aq, \*(Aq\*(Aq, \*(Aqc\*(Aq, \*(Aq\*(Aq )
195 .Ve
196 .IP \fBcatpath()\fR 2
197 .IX Item "catpath()"
198 Takes volume, directory and file portions and returns an entire path. Under
199 Unix, \f(CW$volume\fR is ignored, and directory and file are concatenated. A '/' is
200 inserted if needed (though if the directory portion doesn't start with
201 \&'/' it is not added). On other OSs, \f(CW$volume\fR is significant.
202 .IP abs2rel 2
203 .IX Item "abs2rel"
204 Takes a destination path and an optional base path returns a relative path
205 from the base path to the destination path:
206 .Sp
207 .Vb 2
208 \& $rel_path = File::Spec\->abs2rel( $path ) ;
209 \& $rel_path = File::Spec\->abs2rel( $path, $base ) ;
210 .Ve
211 .Sp
212 If \f(CW$base\fR is not present or '', then \fBcwd()\fR is used. If \f(CW$base\fR is
213 relative, then it is converted to absolute form using
214 "\fBrel2abs()\fR". This means that it is taken to be relative to
215 \&\fBcwd()\fR.
216 .Sp
217 On systems that have a grammar that indicates filenames, this ignores the
218 \&\f(CW$base\fR filename. Otherwise all path components are assumed to be
219 directories.
220 .Sp
221 If \f(CW$path\fR is relative, it is converted to absolute form using "\fBrel2abs()\fR".
222 This means that it is taken to be relative to \fBcwd()\fR.
223 .Sp
224 No checks against the filesystem are made, so the result may not be correct if
225 \&\f(CW$base\fR contains symbolic links. (Apply
226 \&\fBCwd::abs_path()\fR beforehand if that
227 is a concern.) On VMS, there is interaction with the working environment, as
228 logicals and macros are expanded.
229 .Sp
230 Based on code written by Shigio Yamaguchi.
231 .IP \fBrel2abs()\fR 2
232 .IX Item "rel2abs()"
233 Converts a relative path to an absolute path.
234 .Sp
235 .Vb 2
236 \& $abs_path = File::Spec\->rel2abs( $path ) ;
237 \& $abs_path = File::Spec\->rel2abs( $path, $base ) ;
238 .Ve
239 .Sp
240 If \f(CW$base\fR is not present or '', then \fBcwd()\fR is used. If \f(CW$base\fR is
241 relative, then it is converted to absolute form using
242 "\fBrel2abs()\fR". This means that it is taken to be relative to
243 \&\fBcwd()\fR.
244 .Sp
245 On systems that have a grammar that indicates filenames, this ignores
246 the \f(CW$base\fR filename. Otherwise all path components are assumed to be
247 directories.
248 .Sp
249 If \f(CW$path\fR is absolute, it is cleaned up and returned using "\fBcanonpath()\fR".
250 .Sp
251 No checks against the filesystem are made. On VMS, there is
252 interaction with the working environment, as logicals and
253 macros are expanded.
254 .Sp
255 Based on code written by Shigio Yamaguchi.
256 .SH COPYRIGHT
257 .IX Header "COPYRIGHT"
258 Copyright (c) 2004 by the Perl 5 Porters. All rights reserved.
259 .PP
260 This program is free software; you can redistribute it and/or modify
261 it under the same terms as Perl itself.
262 .PP
263 Please submit bug reports at <https://github.com/Perl/perl5/issues>.
264 .SH "SEE ALSO"
265 .IX Header "SEE ALSO"
266 File::Spec