function Local::chmodJailed

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

Overrides ChmodInterface::chmodJailed

File

core/lib/Drupal/Core/FileTransfer/Local.php, line 119

Class

Local
Defines the local connection class for copying files as the httpd user.

Namespace

Drupal\Core\FileTransfer

Code

public function chmodJailed($path, $mode, $recursive) {
    if ($recursive && is_dir($path)) {
        foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) {
            if (@(!chmod($filename, $mode))) {
                throw new FileTransferException('Cannot chmod %path.', NULL, [
                    '%path' => $filename,
                ]);
            }
        }
    }
    elseif (@(!chmod($path, $mode))) {
        throw new FileTransferException('Cannot chmod %path.', NULL, [
            '%path' => $path,
        ]);
    }
}

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