Copies a directory.
We need a separate method to make sure the $destination is in the jail.
string $source: The source path.
string $destination: The destination path.
protected function copyDirectoryJailed($source, $destination) {
if ($this
->isDirectory($destination)) {
$destination = $destination . '/' . drupal_basename($source);
}
$this
->createDirectory($destination);
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
$relative_path = substr($filename, strlen($source));
if ($file
->isDir()) {
$this
->createDirectory($destination . $relative_path);
}
else {
$this
->copyFile($file
->getPathName(), $destination . $relative_path);
}
}
}