public function copyDir($source, $target)
{
$source = $this->getPathInfo($source, 'pathname');
$target = $this->getPathInfo($target, 'pathname');
if (!is_dir($source) || !$this->makeDir($target)) {
return false;
}
if (substr($source, -1) != '/') {
$source .= '/';
}
if (substr($target, -1) != '/') {
$target .= '/';
}
foreach ($this->listDir($source) as $file) {
if (is_dir($source . $file)) {
if (!$this->copyDir($source . $file, $target . $file)) {
return false;
}
} elseif (!$this->copy($source . $file, $target . $file)) {
return false;
}
}
return true;
}