Debian Codegraph @

upstream/mageia-cauldron/man3pm/File::Path.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (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 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "File::Path 3pm"
61 .TH File::Path 3pm 2023-12-22 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 File::Path \- Create or remove directory trees
68 .SH VERSION
69 .IX Header "VERSION"
70 2.18 \- released November 4 2020.
71 .SH SYNOPSIS
72 .IX Header "SYNOPSIS"
73 .Vb 1
74 \& use File::Path qw(make_path remove_tree);
75 \&
76 \& @created = make_path(\*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq);
77 \& @created = make_path(\*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq, {
78 \& verbose => 1,
79 \& mode => 0711,
80 \& });
81 \& make_path(\*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq, {
82 \& chmod => 0777,
83 \& });
84 \&
85 \& $removed_count = remove_tree(\*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq, {
86 \& verbose => 1,
87 \& error => \emy $err_list,
88 \& safe => 1,
89 \& });
90 \&
91 \& # legacy (interface promoted before v2.00)
92 \& @created = mkpath(\*(Aq/foo/bar/baz\*(Aq);
93 \& @created = mkpath(\*(Aq/foo/bar/baz\*(Aq, 1, 0711);
94 \& @created = mkpath([\*(Aq/foo/bar/baz\*(Aq, \*(Aqblurfl/quux\*(Aq], 1, 0711);
95 \& $removed_count = rmtree(\*(Aqfoo/bar/baz\*(Aq, 1, 1);
96 \& $removed_count = rmtree([\*(Aqfoo/bar/baz\*(Aq, \*(Aqblurfl/quux\*(Aq], 1, 1);
97 \&
98 \& # legacy (interface promoted before v2.06)
99 \& @created = mkpath(\*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq, { verbose => 1, mode => 0711 });
100 \& $removed_count = rmtree(\*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq, { verbose => 1, mode => 0711 });
101 .Ve
102 .SH DESCRIPTION
103 .IX Header "DESCRIPTION"
104 This module provides a convenient way to create directories of
105 arbitrary depth and to delete an entire directory subtree from the
106 filesystem.
107 .PP
108 The following functions are provided:
109 .ie n .IP "make_path( $dir1, $dir2, .... )" 4
110 .el .IP "make_path( \f(CW$dir1\fR, \f(CW$dir2\fR, .... )" 4
111 .IX Item "make_path( $dir1, $dir2, .... )"
112 .PD 0
113 .ie n .IP "make_path( $dir1, $dir2, ...., \e%opts )" 4
114 .el .IP "make_path( \f(CW$dir1\fR, \f(CW$dir2\fR, ...., \e%opts )" 4
115 .IX Item "make_path( $dir1, $dir2, ...., %opts )"
116 .PD
117 The \f(CW\*(C`make_path\*(C'\fR function creates the given directories if they don\*(Aqt
118 exist before, much like the Unix command \f(CW\*(C`mkdir \-p\*(C'\fR.
119 .Sp
120 The function accepts a list of directories to be created. Its
121 behaviour may be tuned by an optional hashref appearing as the last
122 parameter on the call.
123 .Sp
124 The function returns the list of directories actually created during
125 the call; in scalar context the number of directories created.
126 .Sp
127 The following keys are recognised in the option hash:
128 .RS 4
129 .ie n .IP "mode => $num" 4
130 .el .IP "mode => \f(CW$num\fR" 4
131 .IX Item "mode => $num"
132 The numeric permissions mode to apply to each created directory
133 (defaults to \f(CW0777\fR), to be modified by the current \f(CW\*(C`umask\*(C'\fR. If the
134 directory already exists (and thus does not need to be created),
135 the permissions will not be modified.
136 .Sp
137 \&\f(CW\*(C`mask\*(C'\fR is recognised as an alias for this parameter.
138 .ie n .IP "chmod => $num" 4
139 .el .IP "chmod => \f(CW$num\fR" 4
140 .IX Item "chmod => $num"
141 Takes a numeric mode to apply to each created directory (not
142 modified by the current \f(CW\*(C`umask\*(C'\fR). If the directory already exists
143 (and thus does not need to be created), the permissions will
144 not be modified.
145 .ie n .IP "verbose => $bool" 4
146 .el .IP "verbose => \f(CW$bool\fR" 4
147 .IX Item "verbose => $bool"
148 If present, will cause \f(CW\*(C`make_path\*(C'\fR to print the name of each directory
149 as it is created. By default nothing is printed.
150 .IP "error => \e$err" 4
151 .IX Item "error => $err"
152 If present, it should be a reference to a scalar.
153 This scalar will be made to reference an array, which will
154 be used to store any errors that are encountered. See the "ERROR
155 HANDLING" section for more information.
156 .Sp
157 If this parameter is not used, certain error conditions may raise
158 a fatal error that will cause the program to halt, unless trapped
159 in an \f(CW\*(C`eval\*(C'\fR block.
160 .ie n .IP "owner => $owner" 4
161 .el .IP "owner => \f(CW$owner\fR" 4
162 .IX Item "owner => $owner"
163 .PD 0
164 .ie n .IP "user => $owner" 4
165 .el .IP "user => \f(CW$owner\fR" 4
166 .IX Item "user => $owner"
167 .ie n .IP "uid => $owner" 4
168 .el .IP "uid => \f(CW$owner\fR" 4
169 .IX Item "uid => $owner"
170 .PD
171 If present, will cause any created directory to be owned by \f(CW$owner\fR.
172 If the value is numeric, it will be interpreted as a uid; otherwise a
173 username is assumed. An error will be issued if the username cannot be
174 mapped to a uid, the uid does not exist or the process lacks the
175 privileges to change ownership.
176 .Sp
177 Ownership of directories that already exist will not be changed.
178 .Sp
179 \&\f(CW\*(C`user\*(C'\fR and \f(CW\*(C`uid\*(C'\fR are aliases of \f(CW\*(C`owner\*(C'\fR.
180 .ie n .IP "group => $group" 4
181 .el .IP "group => \f(CW$group\fR" 4
182 .IX Item "group => $group"
183 If present, will cause any created directory to be owned by the group
184 \&\f(CW$group\fR. If the value is numeric, it will be interpreted as a gid;
185 otherwise a group name is assumed. An error will be issued if the
186 group name cannot be mapped to a gid, the gid does not exist or the
187 process lacks the privileges to change group ownership.
188 .Sp
189 Group ownership of directories that already exist will not be changed.
190 .Sp
191 .Vb 1
192 \& make_path \*(Aq/var/tmp/webcache\*(Aq, {owner=>\*(Aqnobody\*(Aq, group=>\*(Aqnogroup\*(Aq};
193 .Ve
194 .RE
195 .RS 4
196 .RE
197 .ie n .IP "mkpath( $dir )" 4
198 .el .IP "mkpath( \f(CW$dir\fR )" 4
199 .IX Item "mkpath( $dir )"
200 .PD 0
201 .ie n .IP "mkpath( $dir, $verbose, $mode )" 4
202 .el .IP "mkpath( \f(CW$dir\fR, \f(CW$verbose\fR, \f(CW$mode\fR )" 4
203 .IX Item "mkpath( $dir, $verbose, $mode )"
204 .ie n .IP "mkpath( [$dir1, $dir2,...], $verbose, $mode )" 4
205 .el .IP "mkpath( [$dir1, \f(CW$dir2\fR,...], \f(CW$verbose\fR, \f(CW$mode\fR )" 4
206 .IX Item "mkpath( [$dir1, $dir2,...], $verbose, $mode )"
207 .ie n .IP "mkpath( $dir1, $dir2,..., \e%opt )" 4
208 .el .IP "mkpath( \f(CW$dir1\fR, \f(CW$dir2\fR,..., \e%opt )" 4
209 .IX Item "mkpath( $dir1, $dir2,..., %opt )"
210 .PD
211 The \f(CWmkpath()\fR function provide the legacy interface of
212 \&\f(CWmake_path()\fR with a different interpretation of the arguments
213 passed. The behaviour and return value of the function is otherwise
214 identical to \f(CWmake_path()\fR.
215 .ie n .IP "remove_tree( $dir1, $dir2, .... )" 4
216 .el .IP "remove_tree( \f(CW$dir1\fR, \f(CW$dir2\fR, .... )" 4
217 .IX Item "remove_tree( $dir1, $dir2, .... )"
218 .PD 0
219 .ie n .IP "remove_tree( $dir1, $dir2, ...., \e%opts )" 4
220 .el .IP "remove_tree( \f(CW$dir1\fR, \f(CW$dir2\fR, ...., \e%opts )" 4
221 .IX Item "remove_tree( $dir1, $dir2, ...., %opts )"
222 .PD
223 The \f(CW\*(C`remove_tree\*(C'\fR function deletes the given directories and any
224 files and subdirectories they might contain, much like the Unix
225 command \f(CW\*(C`rm \-rf\*(C'\fR or the Windows commands \f(CW\*(C`rmdir /s\*(C'\fR and \f(CW\*(C`rd /s\*(C'\fR.
226 .Sp
227 The function accepts a list of directories to be removed. (In point of fact,
228 it will also accept filesystem entries which are not directories, such as
229 regular files and symlinks. But, as its name suggests, its intent is to
230 remove trees rather than individual files.)
231 .Sp
232 \&\f(CWremove_tree()\fR\*(Aqs behaviour may be tuned by an optional hashref
233 appearing as the last parameter on the call. If an empty string is
234 passed to \f(CW\*(C`remove_tree\*(C'\fR, an error will occur.
235 .Sp
236 \&\fBNOTE:\fR For security reasons, we strongly advise use of the
237 hashref\-as\-final\-argument syntax \-\- specifically, with a setting of the \f(CW\*(C`safe\*(C'\fR
238 element to a true value.
239 .Sp
240 .Vb 6
241 \& remove_tree( $dir1, $dir2, ....,
242 \& {
243 \& safe => 1,
244 \& ... # other key\-value pairs
245 \& },
246 \& );
247 .Ve
248 .Sp
249 The function returns the number of files successfully deleted.
250 .Sp
251 The following keys are recognised in the option hash:
252 .RS 4
253 .ie n .IP "verbose => $bool" 4
254 .el .IP "verbose => \f(CW$bool\fR" 4
255 .IX Item "verbose => $bool"
256 If present, will cause \f(CW\*(C`remove_tree\*(C'\fR to print the name of each file as
257 it is unlinked. By default nothing is printed.
258 .ie n .IP "safe => $bool" 4
259 .el .IP "safe => \f(CW$bool\fR" 4
260 .IX Item "safe => $bool"
261 When set to a true value, will cause \f(CW\*(C`remove_tree\*(C'\fR to skip the files
262 for which the process lacks the required privileges needed to delete
263 files, such as delete privileges on VMS. In other words, the code
264 will make no attempt to alter file permissions. Thus, if the process
265 is interrupted, no filesystem object will be left in a more
266 permissive mode.
267 .ie n .IP "keep_root => $bool" 4
268 .el .IP "keep_root => \f(CW$bool\fR" 4
269 .IX Item "keep_root => $bool"
270 When set to a true value, will cause all files and subdirectories
271 to be removed, except the initially specified directories. This comes
272 in handy when cleaning out an application\*(Aqs scratch directory.
273 .Sp
274 .Vb 1
275 \& remove_tree( \*(Aq/tmp\*(Aq, {keep_root => 1} );
276 .Ve
277 .IP "result => \e$res" 4
278 .IX Item "result => $res"
279 If present, it should be a reference to a scalar.
280 This scalar will be made to reference an array, which will
281 be used to store all files and directories unlinked
282 during the call. If nothing is unlinked, the array will be empty.
283 .Sp
284 .Vb 2
285 \& remove_tree( \*(Aq/tmp\*(Aq, {result => \emy $list} );
286 \& print "unlinked $_\en" for @$list;
287 .Ve
288 .Sp
289 This is a useful alternative to the \f(CW\*(C`verbose\*(C'\fR key.
290 .IP "error => \e$err" 4
291 .IX Item "error => $err"
292 If present, it should be a reference to a scalar.
293 This scalar will be made to reference an array, which will
294 be used to store any errors that are encountered. See the "ERROR
295 HANDLING" section for more information.
296 .Sp
297 Removing things is a much more dangerous proposition than
298 creating things. As such, there are certain conditions that
299 \&\f(CW\*(C`remove_tree\*(C'\fR may encounter that are so dangerous that the only
300 sane action left is to kill the program.
301 .Sp
302 Use \f(CW\*(C`error\*(C'\fR to trap all that is reasonable (problems with
303 permissions and the like), and let it die if things get out
304 of hand. This is the safest course of action.
305 .RE
306 .RS 4
307 .RE
308 .ie n .IP "rmtree( $dir )" 4
309 .el .IP "rmtree( \f(CW$dir\fR )" 4
310 .IX Item "rmtree( $dir )"
311 .PD 0
312 .ie n .IP "rmtree( $dir, $verbose, $safe )" 4
313 .el .IP "rmtree( \f(CW$dir\fR, \f(CW$verbose\fR, \f(CW$safe\fR )" 4
314 .IX Item "rmtree( $dir, $verbose, $safe )"
315 .ie n .IP "rmtree( [$dir1, $dir2,...], $verbose, $safe )" 4
316 .el .IP "rmtree( [$dir1, \f(CW$dir2\fR,...], \f(CW$verbose\fR, \f(CW$safe\fR )" 4
317 .IX Item "rmtree( [$dir1, $dir2,...], $verbose, $safe )"
318 .ie n .IP "rmtree( $dir1, $dir2,..., \e%opt )" 4
319 .el .IP "rmtree( \f(CW$dir1\fR, \f(CW$dir2\fR,..., \e%opt )" 4
320 .IX Item "rmtree( $dir1, $dir2,..., %opt )"
321 .PD
322 The \f(CWrmtree()\fR function provide the legacy interface of
323 \&\f(CWremove_tree()\fR with a different interpretation of the arguments
324 passed. The behaviour and return value of the function is otherwise
325 identical to \f(CWremove_tree()\fR.
326 .Sp
327 \&\fBNOTE:\fR For security reasons, we strongly advise use of the
328 hashref\-as\-final\-argument syntax, specifically with a setting of the \f(CW\*(C`safe\*(C'\fR
329 element to a true value.
330 .Sp
331 .Vb 6
332 \& rmtree( $dir1, $dir2, ....,
333 \& {
334 \& safe => 1,
335 \& ... # other key\-value pairs
336 \& },
337 \& );
338 .Ve
339 .SS "ERROR HANDLING"
340 .IX Subsection "ERROR HANDLING"
341 .IP \fBNOTE:\fR 4
342 .IX Item "NOTE:"
343 The following error handling mechanism is consistent throughout all
344 code paths EXCEPT in cases where the ROOT node is nonexistent. In
345 version 2.11 the maintainers attempted to rectify this inconsistency
346 but too many downstream modules encountered problems. In such case,
347 if you require root node evaluation or error checking prior to calling
348 \&\f(CW\*(C`make_path\*(C'\fR or \f(CW\*(C`remove_tree\*(C'\fR, you should take additional precautions.
349 .PP
350 If \f(CW\*(C`make_path\*(C'\fR or \f(CW\*(C`remove_tree\*(C'\fR encounters an error, a diagnostic
351 message will be printed to \f(CW\*(C`STDERR\*(C'\fR via \f(CW\*(C`carp\*(C'\fR (for non\-fatal
352 errors) or via \f(CW\*(C`croak\*(C'\fR (for fatal errors).
353 .PP
354 If this behaviour is not desirable, the \f(CW\*(C`error\*(C'\fR attribute may be
355 used to hold a reference to a variable, which will be used to store
356 the diagnostics. The variable is made a reference to an array of hash
357 references. Each hash contain a single key/value pair where the key
358 is the name of the file, and the value is the error message (including
359 the contents of \f(CW$!\fR when appropriate). If a general error is
360 encountered the diagnostic key will be empty.
361 .PP
362 An example usage looks like:
363 .PP
364 .Vb 10
365 \& remove_tree( \*(Aqfoo/bar\*(Aq, \*(Aqbar/rat\*(Aq, {error => \emy $err} );
366 \& if ($err && @$err) {
367 \& for my $diag (@$err) {
368 \& my ($file, $message) = %$diag;
369 \& if ($file eq \*(Aq\*(Aq) {
370 \& print "general error: $message\en";
371 \& }
372 \& else {
373 \& print "problem unlinking $file: $message\en";
374 \& }
375 \& }
376 \& }
377 \& else {
378 \& print "No error encountered\en";
379 \& }
380 .Ve
381 .PP
382 Note that if no errors are encountered, \f(CW$err\fR will reference an
383 empty array. This means that \f(CW$err\fR will always end up TRUE; so you
384 need to test \f(CW@$err\fR to determine if errors occurred.
385 .SS NOTES
386 .IX Subsection "NOTES"
387 \&\f(CW\*(C`File::Path\*(C'\fR blindly exports \f(CW\*(C`mkpath\*(C'\fR and \f(CW\*(C`rmtree\*(C'\fR into the
388 current namespace. These days, this is considered bad style, but
389 to change it now would break too much code. Nonetheless, you are
390 invited to specify what it is you are expecting to use:
391 .PP
392 .Vb 1
393 \& use File::Path \*(Aqrmtree\*(Aq;
394 .Ve
395 .PP
396 The routines \f(CW\*(C`make_path\*(C'\fR and \f(CW\*(C`remove_tree\*(C'\fR are \fBnot\fR exported
397 by default. You must specify which ones you want to use.
398 .PP
399 .Vb 1
400 \& use File::Path \*(Aqremove_tree\*(Aq;
401 .Ve
402 .PP
403 Note that a side\-effect of the above is that \f(CW\*(C`mkpath\*(C'\fR and \f(CW\*(C`rmtree\*(C'\fR
404 are no longer exported at all. This is due to the way the \f(CW\*(C`Exporter\*(C'\fR
405 module works. If you are migrating a codebase to use the new
406 interface, you will have to list everything explicitly. But that\*(Aqs
407 just good practice anyway.
408 .PP
409 .Vb 1
410 \& use File::Path qw(remove_tree rmtree);
411 .Ve
412 .PP
413 \fIAPI CHANGES\fR
414 .IX Subsection "API CHANGES"
415 .PP
416 The API was changed in the 2.0 branch. For a time, \f(CW\*(C`mkpath\*(C'\fR and
417 \&\f(CW\*(C`rmtree\*(C'\fR tried, unsuccessfully, to deal with the two different
418 calling mechanisms. This approach was considered a failure.
419 .PP
420 The new semantics are now only available with \f(CW\*(C`make_path\*(C'\fR and
421 \&\f(CW\*(C`remove_tree\*(C'\fR. The old semantics are only available through
422 \&\f(CW\*(C`mkpath\*(C'\fR and \f(CW\*(C`rmtree\*(C'\fR. Users are strongly encouraged to upgrade
423 to at least 2.08 in order to avoid surprises.
424 .PP
425 \fISECURITY CONSIDERATIONS\fR
426 .IX Subsection "SECURITY CONSIDERATIONS"
427 .PP
428 There were race conditions in the 1.x implementations of File::Path\*(Aqs
429 \&\f(CW\*(C`rmtree\*(C'\fR function (although sometimes patched depending on the OS
430 distribution or platform). The 2.0 version contains code to avoid the
431 problem mentioned in CVE\-2002\-0435.
432 .PP
433 See the following pages for more information:
434 .PP
435 .Vb 3
436 \& http://bugs.debian.org/cgi\-bin/bugreport.cgi?bug=286905
437 \& http://www.nntp.perl.org/group/perl.perl5.porters/2005/01/msg97623.html
438 \& http://www.debian.org/security/2005/dsa\-696
439 .Ve
440 .PP
441 Additionally, unless the \f(CW\*(C`safe\*(C'\fR parameter is set (or the
442 third parameter in the traditional interface is TRUE), should a
443 \&\f(CW\*(C`remove_tree\*(C'\fR be interrupted, files that were originally in read\-only
444 mode may now have their permissions set to a read\-write (or "delete
445 OK") mode.
446 .PP
447 The following CVE reports were previously filed against File\-Path and are
448 believed to have been addressed:
449 .IP \(bu 4
450 <http://cve.circl.lu/cve/CVE\-2004\-0452>
451 .IP \(bu 4
452 <http://cve.circl.lu/cve/CVE\-2005\-0448>
453 .PP
454 In February 2017 the cPanel Security Team reported an additional vulnerability
455 in File\-Path. The \f(CWchmod()\fR logic to make directories traversable can be
456 abused to set the mode on an attacker\-chosen file to an attacker\-chosen value.
457 This is due to the time\-of\-check\-to\-time\-of\-use (TOCTTOU) race condition
458 (<https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use>) between the
459 \&\f(CWstat()\fR that decides the inode is a directory and the \f(CWchmod()\fR that tries
460 to make it user\-rwx. CPAN versions 2.13 and later incorporate a patch
461 provided by John Lightsey to address this problem. This vulnerability has
462 been reported as CVE\-2017\-6512.
463 .SH DIAGNOSTICS
464 .IX Header "DIAGNOSTICS"
465 FATAL errors will cause the program to halt (\f(CW\*(C`croak\*(C'\fR), since the
466 problem is so severe that it would be dangerous to continue. (This
467 can always be trapped with \f(CW\*(C`eval\*(C'\fR, but it\*(Aqs not a good idea. Under
468 the circumstances, dying is the best thing to do).
469 .PP
470 SEVERE errors may be trapped using the modern interface. If the
471 they are not trapped, or if the old interface is used, such an error
472 will cause the program will halt.
473 .PP
474 All other errors may be trapped using the modern interface, otherwise
475 they will be \f(CW\*(C`carp\*(C'\fRed about. Program execution will not be halted.
476 .IP "mkdir [path]: [errmsg] (SEVERE)" 4
477 .IX Item "mkdir [path]: [errmsg] (SEVERE)"
478 \&\f(CW\*(C`make_path\*(C'\fR was unable to create the path. Probably some sort of
479 permissions error at the point of departure or insufficient resources
480 (such as free inodes on Unix).
481 .IP "No root path(s) specified" 4
482 .IX Item "No root path(s) specified"
483 \&\f(CW\*(C`make_path\*(C'\fR was not given any paths to create. This message is only
484 emitted if the routine is called with the traditional interface.
485 The modern interface will remain silent if given nothing to do.
486 .IP "No such file or directory" 4
487 .IX Item "No such file or directory"
488 On Windows, if \f(CW\*(C`make_path\*(C'\fR gives you this warning, it may mean that
489 you have exceeded your filesystem\*(Aqs maximum path length.
490 .IP "cannot fetch initial working directory: [errmsg]" 4
491 .IX Item "cannot fetch initial working directory: [errmsg]"
492 \&\f(CW\*(C`remove_tree\*(C'\fR attempted to determine the initial directory by calling
493 \&\f(CW\*(C`Cwd::getcwd\*(C'\fR, but the call failed for some reason. No attempt
494 will be made to delete anything.
495 .IP "cannot stat initial working directory: [errmsg]" 4
496 .IX Item "cannot stat initial working directory: [errmsg]"
497 \&\f(CW\*(C`remove_tree\*(C'\fR attempted to stat the initial directory (after having
498 successfully obtained its name via \f(CW\*(C`getcwd\*(C'\fR), however, the call
499 failed for some reason. No attempt will be made to delete anything.
500 .IP "cannot chdir to [dir]: [errmsg]" 4
501 .IX Item "cannot chdir to [dir]: [errmsg]"
502 \&\f(CW\*(C`remove_tree\*(C'\fR attempted to set the working directory in order to
503 begin deleting the objects therein, but was unsuccessful. This is
504 usually a permissions issue. The routine will continue to delete
505 other things, but this directory will be left intact.
506 .IP "directory [dir] changed before chdir, expected dev=[n] ino=[n], actual dev=[n] ino=[n], aborting. (FATAL)" 4
507 .IX Item "directory [dir] changed before chdir, expected dev=[n] ino=[n], actual dev=[n] ino=[n], aborting. (FATAL)"
508 \&\f(CW\*(C`remove_tree\*(C'\fR recorded the device and inode of a directory, and then
509 moved into it. It then performed a \f(CW\*(C`stat\*(C'\fR on the current directory
510 and detected that the device and inode were no longer the same. As
511 this is at the heart of the race condition problem, the program
512 will die at this point.
513 .IP "cannot make directory [dir] read+writeable: [errmsg]" 4
514 .IX Item "cannot make directory [dir] read+writeable: [errmsg]"
515 \&\f(CW\*(C`remove_tree\*(C'\fR attempted to change the permissions on the current directory
516 to ensure that subsequent unlinkings would not run into problems,
517 but was unable to do so. The permissions remain as they were, and
518 the program will carry on, doing the best it can.
519 .IP "cannot read [dir]: [errmsg]" 4
520 .IX Item "cannot read [dir]: [errmsg]"
521 \&\f(CW\*(C`remove_tree\*(C'\fR tried to read the contents of the directory in order
522 to acquire the names of the directory entries to be unlinked, but
523 was unsuccessful. This is usually a permissions issue. The
524 program will continue, but the files in this directory will remain
525 after the call.
526 .IP "cannot reset chmod [dir]: [errmsg]" 4
527 .IX Item "cannot reset chmod [dir]: [errmsg]"
528 \&\f(CW\*(C`remove_tree\*(C'\fR, after having deleted everything in a directory, attempted
529 to restore its permissions to the original state but failed. The
530 directory may wind up being left behind.
531 .IP "cannot remove [dir] when cwd is [dir]" 4
532 .IX Item "cannot remove [dir] when cwd is [dir]"
533 The current working directory of the program is \fI/some/path/to/here\fR
534 and you are attempting to remove an ancestor, such as \fI/some/path\fR.
535 The directory tree is left untouched.
536 .Sp
537 The solution is to \f(CW\*(C`chdir\*(C'\fR out of the child directory to a place
538 outside the directory tree to be removed.
539 .IP "cannot chdir to [parent\-dir] from [child\-dir]: [errmsg], aborting. (FATAL)" 4
540 .IX Item "cannot chdir to [parent-dir] from [child-dir]: [errmsg], aborting. (FATAL)"
541 \&\f(CW\*(C`remove_tree\*(C'\fR, after having deleted everything and restored the permissions
542 of a directory, was unable to chdir back to the parent. The program
543 halts to avoid a race condition from occurring.
544 .IP "cannot stat prior working directory [dir]: [errmsg], aborting. (FATAL)" 4
545 .IX Item "cannot stat prior working directory [dir]: [errmsg], aborting. (FATAL)"
546 \&\f(CW\*(C`remove_tree\*(C'\fR was unable to stat the parent directory after having returned
547 from the child. Since there is no way of knowing if we returned to
548 where we think we should be (by comparing device and inode) the only
549 way out is to \f(CW\*(C`croak\*(C'\fR.
550 .IP "previous directory [parent\-dir] changed before entering [child\-dir], expected dev=[n] ino=[n], actual dev=[n] ino=[n], aborting. (FATAL)" 4
551 .IX Item "previous directory [parent-dir] changed before entering [child-dir], expected dev=[n] ino=[n], actual dev=[n] ino=[n], aborting. (FATAL)"
552 When \f(CW\*(C`remove_tree\*(C'\fR returned from deleting files in a child directory, a
553 check revealed that the parent directory it returned to wasn\*(Aqt the one
554 it started out from. This is considered a sign of malicious activity.
555 .IP "cannot make directory [dir] writeable: [errmsg]" 4
556 .IX Item "cannot make directory [dir] writeable: [errmsg]"
557 Just before removing a directory (after having successfully removed
558 everything it contained), \f(CW\*(C`remove_tree\*(C'\fR attempted to set the permissions
559 on the directory to ensure it could be removed and failed. Program
560 execution continues, but the directory may possibly not be deleted.
561 .IP "cannot remove directory [dir]: [errmsg]" 4
562 .IX Item "cannot remove directory [dir]: [errmsg]"
563 \&\f(CW\*(C`remove_tree\*(C'\fR attempted to remove a directory, but failed. This may be because
564 some objects that were unable to be removed remain in the directory, or
565 it could be a permissions issue. The directory will be left behind.
566 .IP "cannot restore permissions of [dir] to [0nnn]: [errmsg]" 4
567 .IX Item "cannot restore permissions of [dir] to [0nnn]: [errmsg]"
568 After having failed to remove a directory, \f(CW\*(C`remove_tree\*(C'\fR was unable to
569 restore its permissions from a permissive state back to a possibly
570 more restrictive setting. (Permissions given in octal).
571 .IP "cannot make file [file] writeable: [errmsg]" 4
572 .IX Item "cannot make file [file] writeable: [errmsg]"
573 \&\f(CW\*(C`remove_tree\*(C'\fR attempted to force the permissions of a file to ensure it
574 could be deleted, but failed to do so. It will, however, still attempt
575 to unlink the file.
576 .IP "cannot unlink file [file]: [errmsg]" 4
577 .IX Item "cannot unlink file [file]: [errmsg]"
578 \&\f(CW\*(C`remove_tree\*(C'\fR failed to remove a file. Probably a permissions issue.
579 .IP "cannot restore permissions of [file] to [0nnn]: [errmsg]" 4
580 .IX Item "cannot restore permissions of [file] to [0nnn]: [errmsg]"
581 After having failed to remove a file, \f(CW\*(C`remove_tree\*(C'\fR was also unable
582 to restore the permissions on the file to a possibly less permissive
583 setting. (Permissions given in octal).
584 .IP "unable to map [owner] to a uid, ownership not changed"");" 4
585 .IX Item "unable to map [owner] to a uid, ownership not changed"");"
586 \&\f(CW\*(C`make_path\*(C'\fR was instructed to give the ownership of created
587 directories to the symbolic name [owner], but \f(CW\*(C`getpwnam\*(C'\fR did
588 not return the corresponding numeric uid. The directory will
589 be created, but ownership will not be changed.
590 .IP "unable to map [group] to a gid, group ownership not changed" 4
591 .IX Item "unable to map [group] to a gid, group ownership not changed"
592 \&\f(CW\*(C`make_path\*(C'\fR was instructed to give the group ownership of created
593 directories to the symbolic name [group], but \f(CW\*(C`getgrnam\*(C'\fR did
594 not return the corresponding numeric gid. The directory will
595 be created, but group ownership will not be changed.
596 .SH "SEE ALSO"
597 .IX Header "SEE ALSO"
598 .IP \(bu 4
599 File::Remove
600 .Sp
601 Allows files and directories to be moved to the Trashcan/Recycle
602 Bin (where they may later be restored if necessary) if the operating
603 system supports such functionality. This feature may one day be
604 made available directly in \f(CW\*(C`File::Path\*(C'\fR.
605 .IP \(bu 4
606 File::Find::Rule
607 .Sp
608 When removing directory trees, if you want to examine each file to
609 decide whether to delete it (and possibly leaving large swathes
610 alone), \fIFile::Find::Rule\fR offers a convenient and flexible approach
611 to examining directory trees.
612 .SH "BUGS AND LIMITATIONS"
613 .IX Header "BUGS AND LIMITATIONS"
614 The following describes \fIFile::Path\fR limitations and how to report bugs.
615 .SS "MULTITHREADED APPLICATIONS"
616 .IX Subsection "MULTITHREADED APPLICATIONS"
617 \&\fIFile::Path\fR \f(CW\*(C`rmtree\*(C'\fR and \f(CW\*(C`remove_tree\*(C'\fR will not work with
618 multithreaded applications due to its use of \f(CW\*(C`chdir\*(C'\fR. At this time,
619 no warning or error is generated in this situation. You will
620 certainly encounter unexpected results.
621 .PP
622 The implementation that surfaces this limitation will not be changed. See the
623 \&\fIFile::Path::Tiny\fR module for functionality similar to \fIFile::Path\fR but which does
624 not \f(CW\*(C`chdir\*(C'\fR.
625 .SS "NFS Mount Points"
626 .IX Subsection "NFS Mount Points"
627 \&\fIFile::Path\fR is not responsible for triggering the automounts, mirror mounts,
628 and the contents of network mounted filesystems. If your NFS implementation
629 requires an action to be performed on the filesystem in order for
630 \&\fIFile::Path\fR to perform operations, it is strongly suggested you assure
631 filesystem availability by reading the root of the mounted filesystem.
632 .SS "REPORTING BUGS"
633 .IX Subsection "REPORTING BUGS"
634 Please report all bugs on the RT queue, either via the web interface:
635 .PP
636 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=File\-Path>
637 .PP
638 or by email:
639 .PP
640 .Vb 1
641 \& bug\-File\[email protected]
642 .Ve
643 .PP
644 In either case, please \fBattach\fR patches to the bug report rather than
645 including them inline in the web post or the body of the email.
646 .PP
647 You can also send pull requests to the Github repository:
648 .PP
649 <https://github.com/rpcme/File\-Path>
650 .SH ACKNOWLEDGEMENTS
651 .IX Header "ACKNOWLEDGEMENTS"
652 Paul Szabo identified the race condition originally, and Brendan
653 O\*(AqDea wrote an implementation for Debian that addressed the problem.
654 That code was used as a basis for the current code. Their efforts
655 are greatly appreciated.
656 .PP
657 Gisle Aas made a number of improvements to the documentation for
658 2.07 and his advice and assistance is also greatly appreciated.
659 .SH AUTHORS
660 .IX Header "AUTHORS"
661 Prior authors and maintainers: Tim Bunce, Charles Bailey, and
662 David Landgren <\[email protected]\fR>.
663 .PP
664 Current maintainers are Richard Elberger <\[email protected]\fR> and
665 James (Jim) Keenan <\[email protected]\fR>.
666 .SH CONTRIBUTORS
667 .IX Header "CONTRIBUTORS"
668 Contributors to File::Path, in alphabetical order by first name.
669 .IP <\[email protected]\fR> 1
670 .IX Item "<[email protected]>"
671 .PD 0
672 .IP "Charlie Gonzalez <\[email protected]\fR>" 1
673 .IX Item "Charlie Gonzalez <[email protected]>"
674 .IP "Craig A. Berry <\[email protected]\fR>" 1
675 .IX Item "Craig A. Berry <[email protected]>"
676 .IP "James E Keenan <\[email protected]\fR>" 1
677 .IX Item "James E Keenan <[email protected]>"
678 .IP "John Lightsey <\[email protected]\fR>" 1
679 .IX Item "John Lightsey <[email protected]>"
680 .IP "Nigel Horne <\[email protected]\fR>" 1
681 .IX Item "Nigel Horne <[email protected]>"
682 .IP "Richard Elberger <\[email protected]\fR>" 1
683 .IX Item "Richard Elberger <[email protected]>"
684 .IP "Ryan Yee <\[email protected]\fR>" 1
685 .IX Item "Ryan Yee <[email protected]>"
686 .IP "Skye Shaw <\[email protected]\fR>" 1
687 .IX Item "Skye Shaw <[email protected]>"
688 .IP "Tom Lutz <\[email protected]\fR>" 1
689 .IX Item "Tom Lutz <[email protected]>"
690 .IP "Will Sheppard <\fIwillsheppard@github\fR>" 1
691 .IX Item "Will Sheppard <willsheppard@github>"
692 .PD
693 .SH COPYRIGHT
694 .IX Header "COPYRIGHT"
695 This module is copyright (C) Charles Bailey, Tim Bunce, David Landgren,
696 James Keenan and Richard Elberger 1995\-2020. All rights reserved.
697 .SH LICENSE
698 .IX Header "LICENSE"
699 This library is free software; you can redistribute it and/or modify
700 it under the same terms as Perl itself.