Manual Reference Pages - FILE::NCOPY (3)
File::NCopy - Deprecated module. Use File::Copy::Recursive instead. Copy file, file. Copy file[s] | dir[s], dir
use File::NCopy qw(copy);
# we want to copy the directory recursively
# can also use references to file handles, this is for backward
# compatibility with File::Copy
# we dont specify \1 as the first argument because we dont want to
# copy directories recursively
copy "*", "backup";
# the below are the default config values
$file = File::NCopy->new(
recursive => 0,
preserve => 0,
follow_links => 0,
force_write => 0,
set_permission => \&File::NCopy::u_chmod,
file_check => \&File::NCopy::f_check,
set_times => \&File::NCopy::s_times,
set_permission will take two file names, the original to get the
file permissions from and the new file to set the file permissions
file_check takes two parameters, the file names to check the file to
copy from and the file to copy to. I am using flock for Unix
Default for this is \&File::NCopy::f_check. On Unix you can also use
\&File::NCopy::unix_check. This one compares the inode and device
set_times is used if the preserve attribute is true. It preserves
the access and modification time of the file and also attempts to
set the owner of the file to the original owner. This can be useful
in a script used by root, though enyone can preserve the access and
modification times. This also takes two arguments. The file to get
the stats from and apply the stats to.
On Unix boxes you shouldnt need to worry. On other system you may
want to supply your own sub references.
$file = File::NCopy->new(recursive => 1);
$file = File::NCopy->new(u_chmod => \&my_chmod,f_check => \&my_fcheck);
<B>File::NCopy::copyB> copies files to directories, or a single file to
another file. You can also use a reference to a file handle if you wish
whem doing a file to file copy. The functionality is very similar to
<B>cpB>. If the argument is a directory to directory copy and the
recursive flag is set then it is done recursively like <B>cp -RB>.
In fact it behaves like cp on Unix for the most part.
If called in array context, an array of successful copies is returned,
otherwise the number of succesful copies is returned. If passed a file
handle, its difficult to make sure the file we are copying isnt the
same that we are copying to, since by opening the file in write mode it
gets pooched. To avoid this use file names instead, if at all possible,
especially for the to file. If passed a file handle, it is not closed
when copy returns, files opened by copy are closed.
Copies a file to another file. Or a file to a directory. Or multiple
files and directories to another directory. Or a directory to another
directory. Wildcard arguments are expanded, except for the last
argument which should not be expanded. The file and directory
permissions are set to the orginating files permissions and if preserve
is set the access and modification times are also set. If preserve is
set then the uid and gid will also be attempted to be set, though this
may only for for the men in white hats.
In list context it returns all the names of the files/directories that
were successfully copied. In scalar context it returns the number of
successful copies made. A directory argument is considerd a single
successful copy if it manages to copy anything at all. To make a
directory to directory copy the recursive flag must be set.
Just calls copy. Its there to be compatible with File::Copy.
If used then you can treat this as an object oriented module with some
If used as an object then you can use this to set the recursive
attribute. It can also be set when instantiating with new. The other
attributes must all be set when instantiating the object. If it isnt
specified then directories are not followed.
Attempt to preserve the last modification and access time as well as
user and group ids. This is a useful feature for sysadmins, though the
access and modification time should always be preservable, the uid and
gid may not.
If the link is to a directory and this attribute is true then the
directory is followed and recursively copied. Otherwise a link is made
to the root directory the link points to. eg.
/sys/ is a link to /usr/src/sys/ is a link to /usr/src/i386/sys
then the link /sys/ is actually created in the source directory as a
link to /usr/src/i386/sys/ rather than /usr/src/sys/ since if the link
/usr/src/sys/ is removed then we lost the link even though the directory
we originally intended to link to still exists.
Force the writing of a file even if the permissions are read only on it.
When following links the target directory might not exactly the same as
the source directory. The reason is that we have to make sure we dont
follow circular or dead links. This is really a feature though the
result may not quite resemble the source dir, the overall content will
be the same. :)
From Ken Healy (Version 0.34)
On Win32, The use of backslash for paths is required.
Gabor Egressy <B>gabor AT vmunix.comB>
Copyright (c) 1998 Gabor Egressy. All rights reserved. All wrongs
reversed. This program is free software; you can redistribute and/or
modify it under the same terms as Perl itself.
Some ideas gleaned from File::Copy by Aaron Sherman & Charles Bailey,
but the code was written from scratch.
Patch at versions 0.33, and 0.34 added by MZSANFORD.
0.35, 0.36 - Alexandr Ciornii (alexchorny AT gmail.com)
|perl v5.20.3 ||FILE::NCOPY (3) ||2007-11-26 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.