function SSH::isFile

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

Overrides FileTransfer::isFile

File

core/lib/Drupal/Core/FileTransfer/SSH.php, line 113

Class

SSH
The SSH connection class for the update module.

Namespace

Drupal\Core\FileTransfer

Code

public function isFile($path) {
    $file = escapeshellarg($path);
    $cmd = "[ -f {$file} ] && echo 'yes'";
    if ($output = @ssh2_exec($this->connection, $cmd)) {
        if ($output == 'yes') {
            return TRUE;
        }
        return FALSE;
    }
    else {
        throw new FileTransferException('Cannot check @path.', 0, [
            '@path' => $path,
        ]);
    }
}

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