private function ensuredCopyDir($source, $destination)
{
try {
$filesList = $this->getContents($source);
foreach ($filesList as $file) {
$path = $file['path'];
$dest = explode(DIRECTORY_SEPARATOR, $path, 2);
$dest = $destination . DIRECTORY_SEPARATOR . $dest[1];
if ($file['type'] === Filesystem::TYPE_DIRECTORY) {
$this->copyDir($path, $dest);
} else {
if ($file['type'] === Filesystem::TYPE_FILE) {
$this->copyFile($path, $dest);
}
}
}
return;
} catch (Error $ex) {
} catch (Exception $ex) {
}
throw new WriteException("Directory {$source} could not be copied to {$destination}.");
}