protected function FTPExtension::removeDirectoryJailed

protected FTPExtension::removeDirectoryJailed($directory)

Removes a directory.

Parameters

string $directory: The directory to be removed.

Overrides FileTransfer::removeDirectoryJailed

File

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

Class

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

Namespace

Drupal\Core\FileTransfer

Code

protected function removeDirectoryJailed($directory) {
  $pwd = ftp_pwd($this->connection);
  if (!ftp_chdir($this->connection, $directory)) {
    throw new FileTransferException("Unable to change to directory @directory", NULL, array('@directory' => $directory));
  }
  $list = @ftp_nlist($this->connection, '.');
  if (!$list) {
    $list = array();
  }
  foreach ($list as $item) {
    if ($item == '.' || $item == '..') {
      continue;
    }
    if (@ftp_chdir($this->connection, $item)) {
      ftp_cdup($this->connection);
      $this->removeDirectory(ftp_pwd($this->connection) . '/' . $item);
    }
    else {
      $this->removeFile(ftp_pwd($this->connection) . '/' . $item);
    }
  }
  ftp_chdir($this->connection, $pwd);
  if (!ftp_rmdir($this->connection, $directory)) {
    throw new FileTransferException("Unable to remove to directory @directory", NULL, array('@directory' => $directory));
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!FileTransfer!FTPExtension.php/function/FTPExtension::removeDirectoryJailed/8.1.x