Subject: | Reports failure when copying empty directories |
Hi,
I use File::NCopy 0.34 with ActiveState Perl 5.8.4 on Windows XP.
The module works fine for copying files and non-empty directories, but when an empty directory is copied, it returns zero and reports error "Access is denied".
The directory is indeed copied, it's just the reporting that's broken.
This is true for any directory which contains no files (i.e. a directory containing only empty subdirectories will result in the same reported error).
The bug can be reproduced by running this script (foo.pl):
#!/usr/bin/perl -w
use strict;
use File::NCopy;
my $from = shift @ARGV; # supply path to empty dir to reproduce bug
my $to = shift @ARGV; # dir into which to copy
File::NCopy::copy($from, $to) or die "Failed: $^E";
Sample run:
------------
Show quoted text
>ls E:\Temp\Src\EmptyDir
total 0
Show quoted text>ls E:\Temp\Dst
total 0
Show quoted text>perl foo.pl "E:\Temp\Src\EmptyDir" "E:\Temp\Dst"
Failed: Access is denied at foo.pl line 9
Show quoted text>ls E:\Temp\Dst
EmptyDir
Workaround:
-----------
If this is an issue for you, use File::Find to see if the directory to copy contains any files. If it does not, ignore zero return value from File::NCopy::copy. If it does, then you shouldn't hit this bug, and zero return value from copy would be a true error.