1 filetransfer.inc protected FileTransfer::copyDirectoryJailed($source, $destination)

Copies a directory.

We need a separate method to make the $destination is in the jail.

Parameters

$source: The source path.

$destination: The destination path.

File

core/includes/filetransfer/filetransfer.inc, line 340
Base FileTransfer class.

Class

FileTransfer
@file Base FileTransfer class.

Code

protected function copyDirectoryJailed($source, $destination) {
  if ($this->isDirectory($destination)) {
    $destination = $destination . '/' . backdrop_basename($source);
  }
  $this->createDirectory($destination);
  $directory_iterator = new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS);
  $recursive_iterator = new RecursiveIteratorIterator($directory_iterator, RecursiveIteratorIterator::SELF_FIRST);
  foreach ($recursive_iterator 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);
    }
  }
}