mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-11 08:10:58 +00:00
Merge branch '1.0' into 2.0
This commit is contained in:
commit
53acccdb08
@ -158,7 +158,7 @@ class SFTP extends SSH2
|
|||||||
* Current working directory
|
* Current working directory
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @see self::_realpath()
|
* @see self::realpath()
|
||||||
* @see self::chdir()
|
* @see self::chdir()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -236,6 +236,20 @@ class SFTP extends SSH2
|
|||||||
*/
|
*/
|
||||||
var $sortOptions = array();
|
var $sortOptions = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Canonicalization Flag
|
||||||
|
*
|
||||||
|
* Determines whether or not paths should be canonicalized before being
|
||||||
|
* passed on to the remote server.
|
||||||
|
*
|
||||||
|
* @see self::enablePathCanonicalization()
|
||||||
|
* @see self::disablePathCanonicalization()
|
||||||
|
* @see self::realpath()
|
||||||
|
* @var bool
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $canonicalize_paths = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
*
|
*
|
||||||
@ -575,6 +589,26 @@ class SFTP extends SSH2
|
|||||||
$this->stat_cache = array();
|
$this->stat_cache = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable path canonicalization
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function enablePathCanonicalization()
|
||||||
|
{
|
||||||
|
$this->canonicalize_paths = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable path canonicalization
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function disablePathCanonicalization()
|
||||||
|
{
|
||||||
|
$this->canonicalize_paths = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current directory name
|
* Returns the current directory name
|
||||||
*
|
*
|
||||||
@ -633,13 +667,20 @@ class SFTP extends SSH2
|
|||||||
* SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns
|
* SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns
|
||||||
* the absolute (canonicalized) path.
|
* the absolute (canonicalized) path.
|
||||||
*
|
*
|
||||||
|
* If canonicalize_paths has been disabled using disablePathCanonicalization(), $path is returned as-is.
|
||||||
|
*
|
||||||
* @see self::chdir()
|
* @see self::chdir()
|
||||||
|
* @see self::disablePathCanonicalization()
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _realpath($path)
|
function _realpath($path)
|
||||||
{
|
{
|
||||||
|
if (!$this->canonicalize_paths) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->pwd === false) {
|
if ($this->pwd === false) {
|
||||||
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.9
|
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.9
|
||||||
if (!$this->_send_sftp_packet(NET_SFTP_REALPATH, pack('Na*', strlen($path), $path))) {
|
if (!$this->_send_sftp_packet(NET_SFTP_REALPATH, pack('Na*', strlen($path), $path))) {
|
||||||
@ -1294,7 +1335,7 @@ class SFTP extends SSH2
|
|||||||
/**
|
/**
|
||||||
* Returns general information about a file or symbolic link
|
* Returns general information about a file or symbolic link
|
||||||
*
|
*
|
||||||
* Determines information without calling \phpseclib\Net\SFTP::_realpath().
|
* Determines information without calling \phpseclib\Net\SFTP::realpath().
|
||||||
* The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.
|
* The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.
|
||||||
*
|
*
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
@ -1455,7 +1496,7 @@ class SFTP extends SSH2
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = $this->_realPath($filename);
|
$filename = $this->realpath($filename);
|
||||||
// rather than return what the permissions *should* be, we'll return what they actually are. this will also
|
// rather than return what the permissions *should* be, we'll return what they actually are. this will also
|
||||||
// tell us if the file actually exists.
|
// tell us if the file actually exists.
|
||||||
// incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following:
|
// incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following:
|
||||||
|
Loading…
Reference in New Issue
Block a user