1File::NCopy(3)        User Contributed Perl Documentation       File::NCopy(3)
2
3
4

NAME

6       File::NCopy - Deprecated module. Use File::Copy::Recursive instead.
7       Copy file, file. Copy file[s] ⎪ dir[s], dir
8

SYNOPSIS

10           use File::NCopy qw(copy);
11
12           copy "file","other_file";
13           copy "file1","file2","file3","directory";
14
15           # we want to copy the directory recursively
16           copy \1,"directory1","directory2";
17           copy \1,"file1","file2","directory1","file3","directory2","file4",
18               "directory";
19
20           # can also use references to file handles, this is for backward
21           # compatibility with File::Copy
22           copy \*FILE1,\*FILE2;
23           copy \*FILE1,"file";
24           copy "file1",\*FILE2;
25
26           # we don't specify \1 as the first argument because we don't want to
27           # copy directories recursively
28           copy "*.c","*.pl","programs";
29           copy "*", "backup";
30
31           use File::NCopy;
32
33           # the below are the default config values
34           $file = File::NCopy->new(
35                   'recursive'      => 0,
36                   'preserve'       => 0,
37                   'follow_links'   => 0,
38                   'force_write'   => 0,
39                   'set_permission' => \&File::NCopy::u_chmod,
40                   'file_check'     => \&File::NCopy::f_check,
41                   'set_times'      => \&File::NCopy::s_times,
42           );
43
44           set_permission will take two file names, the original to get the
45           file permissions from and the new file to set the file permissions
46           for.
47
48           file_check takes two parameters, the file names to check the file to
49           copy from and the file to copy to. I am using flock for Unix
50           systems.
51           Default for this is \&File::NCopy::f_check.  On Unix you can also use
52           \&File::NCopy::unix_check.  This one compares the inode and device
53           numbers.
54
55           set_times is used if the preserve attribute is true.  It preserves
56           the access and modification time of the file and also attempts to
57           set the owner of the file to the original owner.  This can be useful
58           in a script used by root, though enyone can preserve the access and
59           modification times. This also takes two arguments.  The file to get
60           the stats from and apply the stats to.
61
62           On Unix boxes you shouldn't need to worry.  On other system you may
63           want to supply your own sub references.
64
65           $file = File::NCopy->new(recursive => 1);
66           $file->copy "file","other_file";
67           $file->copy "directory1","directory2";
68
69           $file = File::NCopy->new(u_chmod => \&my_chmod,f_check => \&my_fcheck);
70           $file->copy "directory1","directory2";
71

DESCRIPTION

73       File::NCopy::copy copies files to directories, or a single file to
74       another file.  You can also use a reference to a file handle if you
75       wish whem doing a file to file copy.  The functionality is very similar
76       to cp.  If the argument is a directory to directory copy and the recur‐
77       sive flag is set then it is done recursively like cp -R.  In fact it
78       behaves like cp on Unix for the most part.  If called in array context,
79       an array of successful copies is returned, otherwise the number of suc‐
80       cesful copies is returned.  If passed a file handle, it's difficult to
81       make sure the file we are copying isn't the same that we are copying
82       to, since by opening the file in write mode it gets pooched.  To avoid
83       this use file names instead, if at all possible, especially for the to
84       file.  If passed a file handle, it is not closed when copy returns,
85       files opened by copy are closed.
86
87       copy
88           Copies a file to another file.  Or a file to a directory.  Or mul‐
89           tiple files and directories to another directory.  Or a directory
90           to another directory.  Wildcard arguments are expanded, except for
91           the last argument which should not be expanded.  The file and
92           directory permissions are set to the orginating file's permissions
93           and if preserve is set the access and modification times are also
94           set.  If preserve is set then the uid and gid will also be
95           attempted to be set, though this may only for for the men in white
96           hats.  In list context it returns all the names of the files/direc‐
97           tories that were successfully copied.  In scalar context it returns
98           the number of successful copies made.  A directory argument is con‐
99           siderd a single successful copy if it manages to copy anything at
100           all.  To make a directory to directory copy the recursive flag must
101           be set.
102
103       cp  Just calls copy.  It's there to be compatible with File::Copy.
104
105       new If used then you can treat this as an object oriented module with
106           some configuration abilities.
107
108       recursive
109           If used as an object then you can use this to set the recursive
110           attribute.  It can also be set when instantiating with new.  The
111           other attributes must all be set when instantiating the object.  If
112           it isn't specified then directories are not followed.
113
114       preserve
115           Attempt to preserve the last modification and access time as well
116           as user and group id's.  This is a useful feature for sysadmins,
117           though the access and modification time should always be preserv‐
118           able, the uid and gid may not.
119
120       follow_links
121           If the link is to a directory and this attribute is true then the
122           directory is followed and recursively copied.  Otherwise a link is
123           made to the root directory the link points to. eg.
124
125           /sys/ is a link to /usr/src/sys/ is a link to /usr/src/i386/sys
126           then the link /sys/ is actually created in the source directory as
127           a link to /usr/src/i386/sys/ rather than /usr/src/sys/ since if the
128           link /usr/src/sys/ is removed then we lost the link even though the
129           directory we originally intended to link to still exists.
130
131       force_write
132           Force the writing of a file even if the permissions are read only
133           on it.
134

EXAMPLE

136       See SYNOPSIS.
137

BUGS

139       When following links the target directory might not exactly the same as
140       the source directory.  The reason is that we have to make sure we don't
141       follow circular or dead links.  This is really a feature though the
142       result may not quite resemble the source dir, the overall content will
143       be the same. :)
144
145       From Ken Healy (Version 0.34)
146
147       On Win32, The use of backslash for paths is required.
148

AUTHOR

150       Gabor Egressy gabor AT vmunix.com
151
152       Copyright (c) 1998 Gabor Egressy.  All rights reserved.  All wrongs
153       reversed.  This program is free software; you can redistribute and/or
154       modify it under the same terms as Perl itself.
155
156       Some ideas gleaned from File::Copy by Aaron Sherman & Charles Bailey,
157       but the code was written from scratch.
158
159       Patch at versions 0.33, and 0.34 added by MZSANFORD.
160
161       0.35, 0.36 - Alexandr Ciornii (alexchorny AT gmail.com)
162
163
164
165perl v5.8.8                       2007-11-26                    File::NCopy(3)
Impressum