function FileTransfer::copyDirectoryJailed

Same name in other branches
  1. 9 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::copyDirectoryJailed()
  2. 8.9.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::copyDirectoryJailed()
  3. 10 core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::copyDirectoryJailed()
  4. 11.x core/lib/Drupal/Core/FileTransfer/FileTransfer.php \Drupal\Core\FileTransfer\FileTransfer::copyDirectoryJailed()

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.

1 call to FileTransfer::copyDirectoryJailed()
FileTransfer::copyDirectory in includes/filetransfer/filetransfer.inc
Copies a directory.
1 method overrides FileTransfer::copyDirectoryJailed()
FileTransferSSH::copyDirectoryJailed in includes/filetransfer/ssh.inc
Copies a directory.

File

includes/filetransfer/filetransfer.inc, line 214

Class

FileTransfer

Code

protected function copyDirectoryJailed($source, $destination) {
    if ($this->isDirectory($destination)) {
        $destination = $destination . '/' . drupal_basename($source);
    }
    $this->createDirectory($destination);
    foreach (new RecursiveIteratorIterator(new SkipDotsRecursiveDirectoryIterator($source), 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);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.