Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / man / man3 / File::Copy.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" 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. | will give a
.\" real vertical bar. \*(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-|\(bv\*(Tr
.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\}
.\"
.\" 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.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" 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::Copy 3"
.TH File::Copy 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
.SH "NAME"
File::Copy \- Copy files or filehandles
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use File::Copy;
.Ve
.PP
.Vb 3
\& copy("file1","file2") or die "Copy failed: $!";
\& copy("Copy.pm",\e*STDOUT);
\& move("/dev1/fileA","/dev2/fileB");
.Ve
.PP
.Vb 1
\& use File::Copy "cp";
.Ve
.PP
.Vb 2
\& $n = FileHandle->new("/a/file","r");
\& cp($n,"x");
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
The File::Copy module provides two basic functions, \f(CW\*(C`copy\*(C'\fR and
\&\f(CW\*(C`move\*(C'\fR, which are useful for getting the contents of a file from
one place to another.
.IP "\(bu" 4
The \f(CW\*(C`copy\*(C'\fR function takes two
parameters: a file to copy from and a file to copy to. Either
argument may be a string, a FileHandle reference or a FileHandle
glob. Obviously, if the first argument is a filehandle of some
sort, it will be read from, and if it is a file \fIname\fR it will
be opened for reading. Likewise, the second argument will be
written to (and created if need be). Trying to copy a file on top
of itself is a fatal error.
.Sp
\&\fBNote that passing in
files as handles instead of names may lead to loss of information
on some operating systems; it is recommended that you use file
names whenever possible.\fR Files are opened in binary mode where
applicable. To get a consistent behaviour when copying from a
filehandle to a file, use \f(CW\*(C`binmode\*(C'\fR on the filehandle.
.Sp
An optional third parameter can be used to specify the buffer
size used for copying. This is the number of bytes from the
first file, that wil be held in memory at any given time, before
being written to the second file. The default buffer size depends
upon the file, but will generally be the whole file (up to 2Mb), or
1k for filehandles that do not reference files (eg. sockets).
.Sp
You may use the syntax \f(CW\*(C`use File::Copy "cp"\*(C'\fR to get at the
\&\*(L"cp\*(R" alias for this function. The syntax is \fIexactly\fR the same.
.IP "\(bu" 4
The \f(CW\*(C`move\*(C'\fR function also takes two parameters: the current name
and the intended name of the file to be moved. If the destination
already exists and is a directory, and the source is not a
directory, then the source file will be renamed into the directory
specified by the destination.
.Sp
If possible, \fImove()\fR will simply rename the file. Otherwise, it copies
the file to the new location and deletes the original. If an error occurs
during this copy-and-delete process, you may be left with a (possibly partial)
copy of the file under the destination name.
.Sp
You may use the \*(L"mv\*(R" alias for this function in the same way that
you may use the \*(L"cp\*(R" alias for \f(CW\*(C`copy\*(C'\fR.
.PP
File::Copy also provides the \f(CW\*(C`syscopy\*(C'\fR routine, which copies the
file specified in the first parameter to the file specified in the
second parameter, preserving OS-specific attributes and file
structure. For Unix systems, this is equivalent to the simple
\&\f(CW\*(C`copy\*(C'\fR routine, which doesn't preserve OS-specific attributes. For
\&\s-1VMS\s0 systems, this calls the \f(CW\*(C`rmscopy\*(C'\fR routine (see below). For \s-1OS/2\s0
systems, this calls the \f(CW\*(C`syscopy\*(C'\fR \s-1XSUB\s0 directly. For Win32 systems,
this calls \f(CW\*(C`Win32::CopyFile\*(C'\fR.
.PP
On Mac \s-1OS\s0 (Classic), \f(CW\*(C`syscopy\*(C'\fR calls \f(CW\*(C`Mac::MoreFiles::FSpFileCopy\*(C'\fR,
if available.
.ie n .Sh "Special behaviour if ""syscopy"" is defined (\s-1OS/2\s0, \s-1VMS\s0 and Win32)"
.el .Sh "Special behaviour if \f(CWsyscopy\fP is defined (\s-1OS/2\s0, \s-1VMS\s0 and Win32)"
.IX Subsection "Special behaviour if syscopy is defined (OS/2, VMS and Win32)"
If both arguments to \f(CW\*(C`copy\*(C'\fR are not file handles,
then \f(CW\*(C`copy\*(C'\fR will perform a \*(L"system copy\*(R" of
the input file to a new output file, in order to preserve file
attributes, indexed file structure, \fIetc.\fR The buffer size
parameter is ignored. If either argument to \f(CW\*(C`copy\*(C'\fR is a
handle to an opened file, then data is copied using Perl
operators, and no effort is made to preserve file attributes
or record structure.
.PP
The system copy routine may also be called directly under \s-1VMS\s0 and \s-1OS/2\s0
as \f(CW\*(C`File::Copy::syscopy\*(C'\fR (or under \s-1VMS\s0 as \f(CW\*(C`File::Copy::rmscopy\*(C'\fR, which
is the routine that does the actual work for syscopy).
.IP "rmscopy($from,$to[,$date_flag])" 4
.IX Item "rmscopy($from,$to[,$date_flag])"
The first and second arguments may be strings, typeglobs, typeglob
references, or objects inheriting from IO::Handle;
they are used in all cases to obtain the
\&\fIfilespec\fR of the input and output files, respectively. The
name and type of the input file are used as defaults for the
output file, if necessary.
.Sp
A new version of the output file is always created, which
inherits the structure and \s-1RMS\s0 attributes of the input file,
except for owner and protections (and possibly timestamps;
see below). All data from the input file is copied to the
output file; if either of the first two parameters to \f(CW\*(C`rmscopy\*(C'\fR
is a file handle, its position is unchanged. (Note that this
means a file handle pointing to the output file will be
associated with an old version of that file after \f(CW\*(C`rmscopy\*(C'\fR
returns, not the newly created version.)
.Sp
The third parameter is an integer flag, which tells \f(CW\*(C`rmscopy\*(C'\fR
how to handle timestamps. If it is < 0, none of the input file's
timestamps are propagated to the output file. If it is > 0, then
it is interpreted as a bitmask: if bit 0 (the \s-1LSB\s0) is set, then
timestamps other than the revision date are propagated; if bit 1
is set, the revision date is propagated. If the third parameter
to \f(CW\*(C`rmscopy\*(C'\fR is 0, then it behaves much like the \s-1DCL\s0 \s-1COPY\s0 command:
if the name or type of the output file was explicitly specified,
then no timestamps are propagated, but if they were taken implicitly
from the input filespec, then all timestamps other than the
revision date are propagated. If this parameter is not supplied,
it defaults to 0.
.Sp
Like \f(CW\*(C`copy\*(C'\fR, \f(CW\*(C`rmscopy\*(C'\fR returns 1 on success. If an error occurs,
it sets \f(CW$!\fR, deletes the output file, and returns 0.
.SH "RETURN"
.IX Header "RETURN"
All functions return 1 on success, 0 on failure.
$! will be set if an error was encountered.
.SH "NOTES"
.IX Header "NOTES"
.IP "\(bu" 4
On Mac \s-1OS\s0 (Classic), the path separator is ':', not '/', and the
current directory is denoted as ':', not '.'. You should be careful
about specifying relative pathnames. While a full path always begins
with a volume name, a relative pathname should always begin with a
\&':'. If specifying a volume name only, a trailing ':' is required.
.Sp
E.g.
.Sp
.Vb 8
\& copy("file1", "tmp"); # creates the file 'tmp' in the current directory
\& copy("file1", ":tmp:"); # creates :tmp:file1
\& copy("file1", ":tmp"); # same as above
\& copy("file1", "tmp"); # same as above, if 'tmp' is a directory (but don't do
\& # that, since it may cause confusion, see example #1)
\& copy("file1", "tmp:file1"); # error, since 'tmp:' is not a volume
\& copy("file1", ":tmp:file1"); # ok, partial path
\& copy("file1", "DataHD:"); # creates DataHD:file1
.Ve
.Sp
.Vb 2
\& move("MacintoshHD:fileA", "DataHD:fileB"); # moves (don't copies) files from one
\& # volume to another
.Ve
.SH "AUTHOR"
.IX Header "AUTHOR"
File::Copy was written by Aaron Sherman \fI<ajs@ajs.com>\fR in 1995,
and updated by Charles Bailey \fI<bailey@newman.upenn.edu>\fR in 1996.