<LI><A HREF="#special behaviour if syscopy is defined (os/2, vms and win32)">Special behaviour if <CODE>syscopy</CODE> is defined (OS/2, VMS and Win32)</A></LI>
<P>The File::Copy module provides two basic functions, <CODE>copy</CODE> and
<CODE>move</CODE>, which are useful for getting the contents of a file from
one place to another.</P>
<UL>
<LI>
The <CODE>copy</CODE> 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 <EM>name</EM> it will
be opened for reading. Likewise, the second argument will be
written to (and created if need be).
<P><STRONG>Note 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.</STRONG> Files are opened in binary mode where
applicable. To get a consistent behaviour when copying from a
filehandle to a file, use <A HREF="../../lib/Pod/perlfunc.html#item_binmode"><CODE>binmode</CODE></A> on the filehandle.</P>
<P>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).</P>
<P>You may use the syntax <CODE>use File::Copy "cp"</CODE> to get at the
``cp'' alias for this function. The syntax is <EM>exactly</EM> the same.</P>
<P></P>
<LI>
The <CODE>move</CODE> 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.
<P>If possible, <CODE>move()</CODE> 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.</P>
<P>You may use the ``mv'' alias for this function in the same way that
you may use the ``cp'' alias for <CODE>copy</CODE>.</P>
<P></P></UL>
<P>File::Copy also provides the <CODE>syscopy</CODE> 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
<CODE>copy</CODE> routine. For VMS systems, this calls the <A HREF="#item_rmscopy"><CODE>rmscopy</CODE></A>
routine (see below). For OS/2 systems, this calls the <CODE>syscopy</CODE>
XSUB directly. For Win32 systems, this calls <CODE>Win32::CopyFile</CODE>.</P>
<P>
<H2><A NAME="special behaviour if syscopy is defined (os/2, vms and win32)">Special behaviour if <CODE>syscopy</CODE> is defined (OS/2, VMS and Win32)</A></H2>
<P>If both arguments to <CODE>copy</CODE> are not file handles,
then <CODE>copy</CODE> will perform a ``system copy'' of
the input file to a new output file, in order to preserve file
attributes, indexed file structure, <EM>etc.</EM> The buffer size
parameter is ignored. If either argument to <CODE>copy</CODE> 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.</P>
<P>The system copy routine may also be called directly under VMS and OS/2
as <CODE>File::Copy::syscopy</CODE> (or under VMS as <CODE>File::Copy::rmscopy</CODE>, which
is the routine that does the actual work for syscopy).</P>