Subject: | dircopy does not report problems from 'copy' or 'symlink' |
It appears that when File::Copy's copy() returns with an error,
or if symlink() returns with an error, dircopy() does not.
I ran into this problem when I tried to copy a directory
structure that included a file for which I didn't have
read privileges. It took a good bit of work before I
discovered that the problem had to do with privileges and
which file was the culprit.
I haven't looked into the 'right' way for a subroutine to report
such errors, but I think the following will work appropriately.
Instead of
copy($org,$new) or return if !defined $buf;
use
copy($org,$new) or return "couldn't copy $org to $new: $!" if !defined $buf;
and, instead of
opendir DIRH, $str or return;
use
opendir DIRH, $str or return "couldn't opendir $str: $!";
for example.
The messages may printed as warnings, which I think is consistent
with the design of dircopy, by using
if (my $recurs_out = $recurs->(@_)) {
warn $recurs_out,"\n";
}
(there must be a better way...) instead of just
$recurs->(@_);
Looking at the code for File::Copy::Recursive, it appears that fcopy
has a similar problem, but fcopy has a different structure so that
probably deserves its own bug entry.