- stat() and lstat() now return information on the file type

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@162 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
Jim Wigginton 2011-06-01 01:51:47 +00:00
parent 2b855b8869
commit 893695d7f3

View File

@ -771,7 +771,7 @@ class Net_SFTP extends Net_SSH2 {
return false; return false;
} }
return $this->_stat($filename, NET_SFTP_STAT); return $this->_identify_type($filename, NET_SFTP_STAT, NET_SFTP_LSTAT);
} }
/** /**
@ -794,7 +794,7 @@ class Net_SFTP extends Net_SSH2 {
return false; return false;
} }
return $this->_stat($filename, NET_SFTP_LSTAT); return $this->_identify_type($filename, NET_SFTP_LSTAT, NET_SFTP_STAT);
} }
/** /**
@ -834,6 +834,33 @@ class Net_SFTP extends Net_SSH2 {
return false; return false;
} }
/**
* Attempt to identify the file type
*
* @param String $path
* @param Array $stat
* @param Array $lstat
* @return Integer
* @access private
*/
function _identify_type($path, $stat1, $stat2)
{
$stat1 = $this->_stat($path, $stat1);
$stat2 = $this->_stat($path, $stat2);
if ($stat1 != $stat2) {
return array_merge($stat1, array('type' => NET_SFTP_TYPE_SYMLINK));
}
$pwd = $this->pwd;
$stat1['type'] = $this->chdir($path) ?
NET_SFTP_TYPE_DIRECTORY :
NET_SFTP_TYPE_REGULAR;
$this->pwd = $pwd;
return $stat1;
}
/** /**
* Returns the file size, in bytes, or false, on failure * Returns the file size, in bytes, or false, on failure
* *