📄 file::path.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "File::Path 3".TH File::Path 3 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"File::Path \- Create or remove directory trees.SH "VERSION".IX Header "VERSION"This document describes version 2.04 of File::Path, released2007\-11\-13..SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\& use File::Path;\&\& # modern\& mkpath( \*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq, {verbose => 1} );\&\& rmtree(\& \*(Aqfoo/bar/baz\*(Aq, \*(Aq/zug/zwang\*(Aq,\& { verbose => 1, error => \emy $err_list }\& );\&\& # traditional\& mkpath([\*(Aq/foo/bar/baz\*(Aq, \*(Aqblurfl/quux\*(Aq], 1, 0711);\& rmtree([\*(Aqfoo/bar/baz\*(Aq, \*(Aqblurfl/quux\*(Aq], 1, 1);.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"The \f(CW\*(C`mkpath\*(C'\fR function provides a convenient way to create directoriesof arbitrary depth. Similarly, the \f(CW\*(C`rmtree\*(C'\fR function provides aconvenient way to delete an entire directory subtree from thefilesystem, much like the Unix command \f(CW\*(C`rm \-r\*(C'\fR..PPBoth functions may be called in one of two ways, the traditional,compatible with code written since the dawn of time, and modern,that offers a more flexible and readable idiom. New code should usethe modern interface..Sh "\s-1FUNCTIONS\s0".IX Subsection "FUNCTIONS"The modern way of calling \f(CW\*(C`mkpath\*(C'\fR and \f(CW\*(C`rmtree\*(C'\fR is with a listof directories to create, or remove, respectively, followed by anoptional hash reference containing keys to control thefunction's behaviour..PP\fI\f(CI\*(C`mkpath\*(C'\fI\fR.IX Subsection "mkpath".PPThe following keys are recognised as parameters to \f(CW\*(C`mkpath\*(C'\fR.The function returns the list of files actually created during thecall..PP.Vb 5\& my @created = mkpath(\& qw(/tmp /flub /home/nobody),\& {verbose => 1, mode => 0750},\& );\& print "created $_\en" for @created;.Ve.IP "mode" 4.IX Item "mode"The numeric permissions mode to apply to each created directory(defaults to 0777), to be modified by the current \f(CW\*(C`umask\*(C'\fR. If thedirectory already exists (and thus does not need to be created),the permissions will not be modified..Sp\&\f(CW\*(C`mask\*(C'\fR is recognised as an alias for this parameter..IP "verbose" 4.IX Item "verbose"If present, will cause \f(CW\*(C`mkpath\*(C'\fR to print the name of each directoryas it is created. By default nothing is printed..IP "error" 4.IX Item "error"If present, will be interpreted as a reference to a list, and willbe used to store any errors that are encountered. See the \s-1ERROR\s0\&\s-1HANDLING\s0 section for more information..SpIf this parameter is not used, certain error conditions may raisea fatal error that will cause the program will halt, unless trappedin an \f(CW\*(C`eval\*(C'\fR block..PP\fI\f(CI\*(C`rmtree\*(C'\fI\fR.IX Subsection "rmtree".IP "verbose" 4.IX Item "verbose"If present, will cause \f(CW\*(C`rmtree\*(C'\fR to print the name of each file asit is unlinked. By default nothing is printed..IP "safe" 4.IX Item "safe"When set to a true value, will cause \f(CW\*(C`rmtree\*(C'\fR to skip the filesfor which the process lacks the required privileges needed to deletefiles, such as delete privileges on \s-1VMS\s0. In other words, the codewill make no attempt to alter file permissions. Thus, if the processis interrupted, no filesystem object will be left in a morepermissive mode..IP "keep_root" 4.IX Item "keep_root"When set to a true value, will cause all files and subdirectoriesto be removed, except the initially specified directories. This comesin handy when cleaning out an application's scratch directory..Sp.Vb 1\& rmtree( \*(Aq/tmp\*(Aq, {keep_root => 1} );.Ve.IP "result" 4.IX Item "result"If present, will be interpreted as a reference to a list, and willbe used to store the list of all files and directories unlinkedduring the call. If nothing is unlinked, a reference to an emptylist is returned (rather than \f(CW\*(C`undef\*(C'\fR)..Sp.Vb 2\& rmtree( \*(Aq/tmp\*(Aq, {result => \emy $list} );\& print "unlinked $_\en" for @$list;.Ve.SpThis is a useful alternative to the \f(CW\*(C`verbose\*(C'\fR key..IP "error" 4.IX Item "error"If present, will be interpreted as a reference to a list,and will be used to store any errors that are encountered.See the \s-1ERROR\s0 \s-1HANDLING\s0 section for more information..SpRemoving things is a much more dangerous proposition thancreating things. As such, there are certain conditions that\&\f(CW\*(C`rmtree\*(C'\fR may encounter that are so dangerous that the onlysane action left is to kill the program..SpUse \f(CW\*(C`error\*(C'\fR to trap all that is reasonable (problems withpermissions and the like), and let it die if things get outof hand. This is the safest course of action..Sh "\s-1TRADITIONAL\s0 \s-1INTERFACE\s0".IX Subsection "TRADITIONAL INTERFACE"The old interfaces of \f(CW\*(C`mkpath\*(C'\fR and \f(CW\*(C`rmtree\*(C'\fR take a reference toa list of directories (to create or remove), followed by a seriesof positional, numeric, modal parameters that control their behaviour..PPThis design made it difficult to add additional functionality, aswell as posed the problem of what to do when the calling code onlyneeds to set the last parameter. Even though the code doesn't carehow the initial positional parameters are set, the programmer isforced to learn what the defaults are, and specify them..PPWorse, if it turns out in the future that it would make more senseto change the default behaviour of the first parameter (for example,to avoid a security vulnerability), all existing code will remainhard-wired to the wrong defaults..PPFinally, a series of numeric parameters are much less self-documentingin terms of communicating to the reader what the code is doing. Namedparameters do not have this problem..PPIn the traditional \s-1API\s0, \f(CW\*(C`mkpath\*(C'\fR takes three arguments:.IP "\(bu" 4The name of the path to create, or a reference to a list of pathsto create,.IP "\(bu" 4a boolean value, which if \s-1TRUE\s0 will cause \f(CW\*(C`mkpath\*(C'\fR to print thename of each directory as it is created (defaults to \s-1FALSE\s0), and.IP "\(bu" 4the numeric mode to use when creating the directories (defaults to0777), to be modified by the current umask..PPIt returns a list of all directories (including intermediates, determinedusing the Unix '/' separator) created. In scalar context it returnsthe number of directories created..PP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -