From edb54123a10d207b015c3c05b8db25b2fed8d541 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Tue, 7 Dec 2010 17:16:26 -0500 Subject: [PATCH] Tweaks to improve ssh2 VFS performance --- framework/VFS/lib/VFS/ssh2.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/framework/VFS/lib/VFS/ssh2.php b/framework/VFS/lib/VFS/ssh2.php index 00e512981..f4b14f95b 100644 --- a/framework/VFS/lib/VFS/ssh2.php +++ b/framework/VFS/lib/VFS/ssh2.php @@ -594,6 +594,24 @@ class VFS_ssh2 extends VFS } /** + * Returns if a given file or folder exists in a folder. + * + * @param string $path The path to the folder. + * @param string $name The file or folder name. + * + * @return boolean True if it exists, false otherwise. + */ + function exists($path, $name) + { + $conn = $this->_connect(); + if (is_a($conn, 'PEAR_Error')) { + return $conn; + } + + return !(ssh2_sftp_stat($this->_sftp, ssh2_sftp_realpath($this->_sftp, $path) . '/' . $name) === false); + } + + /** * Returns a sorted list of folders in the specified directory. * * @param string $path The path of the directory to get the @@ -870,7 +888,8 @@ class VFS_ssh2 extends VFS { return 'ssh2.sftp://' . $this->_params['username'] . ':' . $this->_params['password'] . '@' . $this->_params['hostspec'] . - ':' . $this->_params['port'] . $remote; + ':' . $this->_params['port'] . + ssh2_sftp_realpath($this->_sftp, $remote); } } -- 2.11.0