function FTPExtension::chmodJailed

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

Overrides ChmodInterface::chmodJailed

File

core/lib/Drupal/Core/FileTransfer/FTPExtension.php, line 104

Class

FTPExtension
Defines a file transfer class using the PHP FTP extension.

Namespace

Drupal\Core\FileTransfer

Code

public function chmodJailed($path, $mode, $recursive) {
    if (!ftp_chmod($this->connection, $mode, $path)) {
        throw new FileTransferException("Unable to set permissions on %file", 0, [
            '%file' => $path,
        ]);
    }
    if ($this->isDirectory($path) && $recursive) {
        $file_list = @ftp_nlist($this->connection, $path);
        if (!$file_list) {
            // empty directory - returns false
            return;
        }
        foreach ($file_list as $file) {
            $this->chmodJailed($file, $mode, $recursive);
        }
    }
}

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