Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / man / man3 / File::Copy.3
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
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 "2001-09-21" "perl v5.8.8" "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") or die "Copy failed: $!";
143\& copy("Copy.pm",\e*STDOUT);
144\& move("/dev1/fileA","/dev2/fileB");
145.Ve
146.PP
147.Vb 1
148\& use File::Copy "cp";
149.Ve
150.PP
151.Vb 2
152\& $n = FileHandle->new("/a/file","r");
153\& cp($n,"x");
154.Ve
155.SH "DESCRIPTION"
156.IX Header "DESCRIPTION"
157The File::Copy module provides two basic functions, \f(CW\*(C`copy\*(C'\fR and
158\&\f(CW\*(C`move\*(C'\fR, which are useful for getting the contents of a file from
159one place to another.
160.IP "\(bu" 4
161The \f(CW\*(C`copy\*(C'\fR function takes two
162parameters: a file to copy from and a file to copy to. Either
163argument may be a string, a FileHandle reference or a FileHandle
164glob. Obviously, if the first argument is a filehandle of some
165sort, it will be read from, and if it is a file \fIname\fR it will
166be opened for reading. Likewise, the second argument will be
167written to (and created if need be). Trying to copy a file on top
168of itself is a fatal error.
169.Sp
170\&\fBNote that passing in
171files as handles instead of names may lead to loss of information
172on some operating systems; it is recommended that you use file
173names whenever possible.\fR Files are opened in binary mode where
174applicable. To get a consistent behaviour when copying from a
175filehandle to a file, use \f(CW\*(C`binmode\*(C'\fR on the filehandle.
176.Sp
177An optional third parameter can be used to specify the buffer
178size used for copying. This is the number of bytes from the
179first file, that wil be held in memory at any given time, before
180being written to the second file. The default buffer size depends
181upon the file, but will generally be the whole file (up to 2Mb), or
1821k for filehandles that do not reference files (eg. sockets).
183.Sp
184You may use the syntax \f(CW\*(C`use File::Copy "cp"\*(C'\fR to get at the
185\&\*(L"cp\*(R" alias for this function. The syntax is \fIexactly\fR the same.
186.IP "\(bu" 4
187The \f(CW\*(C`move\*(C'\fR function also takes two parameters: the current name
188and the intended name of the file to be moved. If the destination
189already exists and is a directory, and the source is not a
190directory, then the source file will be renamed into the directory
191specified by the destination.
192.Sp
193If possible, \fImove()\fR will simply rename the file. Otherwise, it copies
194the file to the new location and deletes the original. If an error occurs
195during this copy-and-delete process, you may be left with a (possibly partial)
196copy of the file under the destination name.
197.Sp
198You may use the \*(L"mv\*(R" alias for this function in the same way that
199you may use the \*(L"cp\*(R" alias for \f(CW\*(C`copy\*(C'\fR.
200.PP
201File::Copy also provides the \f(CW\*(C`syscopy\*(C'\fR routine, which copies the
202file specified in the first parameter to the file specified in the
203second parameter, preserving OS-specific attributes and file
204structure. For Unix systems, this is equivalent to the simple
205\&\f(CW\*(C`copy\*(C'\fR routine, which doesn't preserve OS-specific attributes. For
206\&\s-1VMS\s0 systems, this calls the \f(CW\*(C`rmscopy\*(C'\fR routine (see below). For \s-1OS/2\s0
207systems, this calls the \f(CW\*(C`syscopy\*(C'\fR \s-1XSUB\s0 directly. For Win32 systems,
208this calls \f(CW\*(C`Win32::CopyFile\*(C'\fR.
209.PP
210On Mac \s-1OS\s0 (Classic), \f(CW\*(C`syscopy\*(C'\fR calls \f(CW\*(C`Mac::MoreFiles::FSpFileCopy\*(C'\fR,
211if available.
212.ie n .Sh "Special behaviour if ""syscopy"" is defined (\s-1OS/2\s0, \s-1VMS\s0 and Win32)"
213.el .Sh "Special behaviour if \f(CWsyscopy\fP is defined (\s-1OS/2\s0, \s-1VMS\s0 and Win32)"
214.IX Subsection "Special behaviour if syscopy is defined (OS/2, VMS and Win32)"
215If both arguments to \f(CW\*(C`copy\*(C'\fR are not file handles,
216then \f(CW\*(C`copy\*(C'\fR will perform a \*(L"system copy\*(R" of
217the input file to a new output file, in order to preserve file
218attributes, indexed file structure, \fIetc.\fR The buffer size
219parameter is ignored. If either argument to \f(CW\*(C`copy\*(C'\fR is a
220handle to an opened file, then data is copied using Perl
221operators, and no effort is made to preserve file attributes
222or record structure.
223.PP
224The system copy routine may also be called directly under \s-1VMS\s0 and \s-1OS/2\s0
225as \f(CW\*(C`File::Copy::syscopy\*(C'\fR (or under \s-1VMS\s0 as \f(CW\*(C`File::Copy::rmscopy\*(C'\fR, which
226is the routine that does the actual work for syscopy).
227.IP "rmscopy($from,$to[,$date_flag])" 4
228.IX Item "rmscopy($from,$to[,$date_flag])"
229The first and second arguments may be strings, typeglobs, typeglob
230references, or objects inheriting from IO::Handle;
231they are used in all cases to obtain the
232\&\fIfilespec\fR of the input and output files, respectively. The
233name and type of the input file are used as defaults for the
234output file, if necessary.
235.Sp
236A new version of the output file is always created, which
237inherits the structure and \s-1RMS\s0 attributes of the input file,
238except for owner and protections (and possibly timestamps;
239see below). All data from the input file is copied to the
240output file; if either of the first two parameters to \f(CW\*(C`rmscopy\*(C'\fR
241is a file handle, its position is unchanged. (Note that this
242means a file handle pointing to the output file will be
243associated with an old version of that file after \f(CW\*(C`rmscopy\*(C'\fR
244returns, not the newly created version.)
245.Sp
246The third parameter is an integer flag, which tells \f(CW\*(C`rmscopy\*(C'\fR
247how to handle timestamps. If it is < 0, none of the input file's
248timestamps are propagated to the output file. If it is > 0, then
249it is interpreted as a bitmask: if bit 0 (the \s-1LSB\s0) is set, then
250timestamps other than the revision date are propagated; if bit 1
251is set, the revision date is propagated. If the third parameter
252to \f(CW\*(C`rmscopy\*(C'\fR is 0, then it behaves much like the \s-1DCL\s0 \s-1COPY\s0 command:
253if the name or type of the output file was explicitly specified,
254then no timestamps are propagated, but if they were taken implicitly
255from the input filespec, then all timestamps other than the
256revision date are propagated. If this parameter is not supplied,
257it defaults to 0.
258.Sp
259Like \f(CW\*(C`copy\*(C'\fR, \f(CW\*(C`rmscopy\*(C'\fR returns 1 on success. If an error occurs,
260it sets \f(CW$!\fR, deletes the output file, and returns 0.
261.SH "RETURN"
262.IX Header "RETURN"
263All functions return 1 on success, 0 on failure.
264$! will be set if an error was encountered.
265.SH "NOTES"
266.IX Header "NOTES"
267.IP "\(bu" 4
268On Mac \s-1OS\s0 (Classic), the path separator is ':', not '/', and the
269current directory is denoted as ':', not '.'. You should be careful
270about specifying relative pathnames. While a full path always begins
271with a volume name, a relative pathname should always begin with a
272\&':'. If specifying a volume name only, a trailing ':' is required.
273.Sp
274E.g.
275.Sp
276.Vb 8
277\& copy("file1", "tmp"); # creates the file 'tmp' in the current directory
278\& copy("file1", ":tmp:"); # creates :tmp:file1
279\& copy("file1", ":tmp"); # same as above
280\& copy("file1", "tmp"); # same as above, if 'tmp' is a directory (but don't do
281\& # that, since it may cause confusion, see example #1)
282\& copy("file1", "tmp:file1"); # error, since 'tmp:' is not a volume
283\& copy("file1", ":tmp:file1"); # ok, partial path
284\& copy("file1", "DataHD:"); # creates DataHD:file1
285.Ve
286.Sp
287.Vb 2
288\& move("MacintoshHD:fileA", "DataHD:fileB"); # moves (don't copies) files from one
289\& # volume to another
290.Ve
291.SH "AUTHOR"
292.IX Header "AUTHOR"
293File::Copy was written by Aaron Sherman \fI<ajs@ajs.com>\fR in 1995,
294and updated by Charles Bailey \fI<bailey@newman.upenn.edu>\fR in 1996.