Subject: | dircopy with $MaxDepth fails on quad-tree directory structure |
Date: | Mon, 9 Apr 2012 10:46:51 -0500 |
To: | bug-File-Copy-Recursive [...] rt.cpan.org |
From: | Lenny Leblanc <lleblanc [...] macroelite.ca> |
When trying to do a dircopy on a quad-tree directory structure using
MaxDepth you get the MaxDepth for the first tree of the directory but then
the rest fail still thinking that $level is at our $MaxDepth specified.
Example:
/0
/0/0.png
/0/1.png
/0/0/1.png
/1/0.png
/1
... etc
In this case setting $File::Copy::Recursive::MaxDepth = 2 will copy the
/0/0/0.png and /0/0/1.png but then fail to copy /0/1/0.png.
I spent some time digging through the source and have it working properly
by adding $level--; to the recursive section of dircopy when we are exiting
normally.
---------------------
sub dircopy {
... snip ...
$recurs = sub {
... snip ...
$level--;* #added this line*
1;
};
$recurs->($_zero, $_one, $_[2]) or return;
return wantarray ? ($filen,$dirn,$level) : $filen;
}
-----------------------
Sorry about the formatting on this... ugh. Can't seem to login to post this
bug so I'm trying this email method... ?
--
Lenny Leblanc