function FileTransferFTPExtension::removeDirectoryJailed

Overrides FileTransfer::removeDirectoryJailed

File

includes/filetransfer/ftp.inc, line 76

Class

FileTransferFTPExtension

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,
        ));
    }
}

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