Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / File::Copy.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "File::Copy 3"
132.TH File::Copy 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134File::Copy \- Copy files or filehandles
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& use File::Copy;
139.Ve
140.PP
141.Vb 3
142\& copy("file1","file2");
143\& copy("Copy.pm",\e*STDOUT);'
144\& move("/dev1/fileA","/dev2/fileB");
145.Ve
146.PP
147.Vb 2
148\& use POSIX;
149\& use File::Copy cp;
150.Ve
151.PP
152.Vb 2
153\& $n = FileHandle->new("/a/file","r");
154\& cp($n,"x");'
155.Ve
156.SH "DESCRIPTION"
157.IX Header "DESCRIPTION"
158The File::Copy module provides two basic functions, \f(CW\*(C`copy\*(C'\fR and
159\&\f(CW\*(C`move\*(C'\fR, which are useful for getting the contents of a file from
160one place to another.
161.IP "\(bu" 4
162The \f(CW\*(C`copy\*(C'\fR function takes two
163parameters: a file to copy from and a file to copy to. Either
164argument may be a string, a FileHandle reference or a FileHandle
165glob. Obviously, if the first argument is a filehandle of some
166sort, it will be read from, and if it is a file \fIname\fR it will
167be opened for reading. Likewise, the second argument will be
168written to (and created if need be). Trying to copy a file on top
169of itself is a fatal error.
170.Sp
171\&\fBNote that passing in
172files as handles instead of names may lead to loss of information
173on some operating systems; it is recommended that you use file
174names whenever possible.\fR Files are opened in binary mode where
175applicable. To get a consistent behaviour when copying from a
176filehandle to a file, use \f(CW\*(C`binmode\*(C'\fR on the filehandle.
177.Sp
178An optional third parameter can be used to specify the buffer
179size used for copying. This is the number of bytes from the
180first file, that wil be held in memory at any given time, before
181being written to the second file. The default buffer size depends
182upon the file, but will generally be the whole file (up to 2Mb), or
1831k for filehandles that do not reference files (eg. sockets).
184.Sp
185You may use the syntax \f(CW\*(C`use File::Copy "cp"\*(C'\fR to get at the
186\&\*(L"cp\*(R" alias for this function. The syntax is \fIexactly\fR the same.
187.IP "\(bu" 4
188The \f(CW\*(C`move\*(C'\fR function also takes two parameters: the current name
189and the intended name of the file to be moved. If the destination
190already exists and is a directory, and the source is not a
191directory, then the source file will be renamed into the directory
192specified by the destination.
193.Sp
194If possible, \fImove()\fR will simply rename the file. Otherwise, it copies
195the file to the new location and deletes the original. If an error occurs
196during this copy-and-delete process, you may be left with a (possibly partial)
197copy of the file under the destination name.
198.Sp
199You may use the \*(L"mv\*(R" alias for this function in the same way that
200you may use the \*(L"cp\*(R" alias for \f(CW\*(C`copy\*(C'\fR.
201.PP
202File::Copy also provides the \f(CW\*(C`syscopy\*(C'\fR routine, which copies the
203file specified in the first parameter to the file specified in the
204second parameter, preserving OS-specific attributes and file
205structure. For Unix systems, this is equivalent to the simple
206\&\f(CW\*(C`copy\*(C'\fR routine, which doesn't preserve OS-specific attributes. For
207\&\s-1VMS\s0 systems, this calls the \f(CW\*(C`rmscopy\*(C'\fR routine (see below). For \s-1OS/2\s0
208systems, this calls the \f(CW\*(C`syscopy\*(C'\fR \s-1XSUB\s0 directly. For Win32 systems,
209this calls \f(CW\*(C`Win32::CopyFile\*(C'\fR.
210.PP
211On Mac \s-1OS\s0 (Classic), \f(CW\*(C`syscopy\*(C'\fR calls \f(CW\*(C`Mac::MoreFiles::FSpFileCopy\*(C'\fR,
212if available.
213.ie n .Sh "Special behaviour if ""syscopy"" is defined (\s-1OS/2\s0, \s-1VMS\s0 and Win32)"
214.el .Sh "Special behaviour if \f(CWsyscopy\fP is defined (\s-1OS/2\s0, \s-1VMS\s0 and Win32)"
215.IX Subsection "Special behaviour if syscopy is defined (OS/2, VMS and Win32)"
216If both arguments to \f(CW\*(C`copy\*(C'\fR are not file handles,
217then \f(CW\*(C`copy\*(C'\fR will perform a \*(L"system copy\*(R" of
218the input file to a new output file, in order to preserve file
219attributes, indexed file structure, \fIetc.\fR The buffer size
220parameter is ignored. If either argument to \f(CW\*(C`copy\*(C'\fR is a
221handle to an opened file, then data is copied using Perl
222operators, and no effort is made to preserve file attributes
223or record structure.
224.PP
225The system copy routine may also be called directly under \s-1VMS\s0 and \s-1OS/2\s0
226as \f(CW\*(C`File::Copy::syscopy\*(C'\fR (or under \s-1VMS\s0 as \f(CW\*(C`File::Copy::rmscopy\*(C'\fR, which
227is the routine that does the actual work for syscopy).
228.IP "rmscopy($from,$to[,$date_flag])" 4
229.IX Item "rmscopy($from,$to[,$date_flag])"
230The first and second arguments may be strings, typeglobs, typeglob
231references, or objects inheriting from IO::Handle;
232they are used in all cases to obtain the
233\&\fIfilespec\fR of the input and output files, respectively. The
234name and type of the input file are used as defaults for the
235output file, if necessary.
236.Sp
237A new version of the output file is always created, which
238inherits the structure and \s-1RMS\s0 attributes of the input file,
239except for owner and protections (and possibly timestamps;
240see below). All data from the input file is copied to the
241output file; if either of the first two parameters to \f(CW\*(C`rmscopy\*(C'\fR
242is a file handle, its position is unchanged. (Note that this
243means a file handle pointing to the output file will be
244associated with an old version of that file after \f(CW\*(C`rmscopy\*(C'\fR
245returns, not the newly created version.)
246.Sp
247The third parameter is an integer flag, which tells \f(CW\*(C`rmscopy\*(C'\fR
248how to handle timestamps. If it is < 0, none of the input file's
249timestamps are propagated to the output file. If it is > 0, then
250it is interpreted as a bitmask: if bit 0 (the \s-1LSB\s0) is set, then
251timestamps other than the revision date are propagated; if bit 1
252is set, the revision date is propagated. If the third parameter
253to \f(CW\*(C`rmscopy\*(C'\fR is 0, then it behaves much like the \s-1DCL\s0 \s-1COPY\s0 command:
254if the name or type of the output file was explicitly specified,
255then no timestamps are propagated, but if they were taken implicitly
256from the input filespec, then all timestamps other than the
257revision date are propagated. If this parameter is not supplied,
258it defaults to 0.
259.Sp
260Like \f(CW\*(C`copy\*(C'\fR, \f(CW\*(C`rmscopy\*(C'\fR returns 1 on success. If an error occurs,
261it sets \f(CW$!\fR, deletes the output file, and returns 0.
262.SH "RETURN"
263.IX Header "RETURN"
264All functions return 1 on success, 0 on failure.
265$! will be set if an error was encountered.
266.SH "NOTES"
267.IX Header "NOTES"
268.IP "\(bu" 4
269On Mac \s-1OS\s0 (Classic), the path separator is ':', not '/', and the
270current directory is denoted as ':', not '.'. You should be careful
271about specifying relative pathnames. While a full path always begins
272with a volume name, a relative pathname should always begin with a
273\&':'. If specifying a volume name only, a trailing ':' is required.
274.Sp
275E.g.
276.Sp
277.Vb 8
278\& copy("file1", "tmp"); # creates the file 'tmp' in the current directory
279\& copy("file1", ":tmp:"); # creates :tmp:file1
280\& copy("file1", ":tmp"); # same as above
281\& copy("file1", "tmp"); # same as above, if 'tmp' is a directory (but don't do
282\& # that, since it may cause confusion, see example #1)
283\& copy("file1", "tmp:file1"); # error, since 'tmp:' is not a volume
284\& copy("file1", ":tmp:file1"); # ok, partial path
285\& copy("file1", "DataHD:"); # creates DataHD:file1
286.Ve
287.Sp
288.Vb 2
289\& move("MacintoshHD:fileA", "DataHD:fileB"); # moves (don't copies) files from one
290\& # volume to another
291.Ve
292.SH "AUTHOR"
293.IX Header "AUTHOR"
294File::Copy was written by Aaron Sherman \fI<ajs@ajs.com>\fR in 1995,
295and updated by Charles Bailey \fI<bailey@newman.upenn.edu>\fR in 1996.