Merge pull request #352 from terrafrost/sftp-stream-changes

SFTP Stream changes

* terrafrost/sftp-stream-changes:
  SFTP/Stream: fix capatilization
  SFTP/Stream: add explanation as to why nlist() is used here
  SFTP/Stream: use $scheme instead of 'sftp'
This commit is contained in:
Andreas Fischer 2014-05-30 00:00:04 +02:00
commit 6805704b4f

View File

@ -180,24 +180,24 @@ class Net_SFTP_Stream
if (isset($this->context)) { if (isset($this->context)) {
$context = stream_context_get_options($this->context); $context = stream_context_get_options($this->context);
} }
if (isset($context['sftp']['session'])) { if (isset($context[$scheme]['session'])) {
$sftp = $context['sftp']['session']; $sftp = $context[$scheme]['session'];
} }
if (isset($context['sftp']['sftp'])) { if (isset($context[$scheme]['sftp'])) {
$sftp = $context['sftp']['sftp']; $sftp = $context[$scheme]['sftp'];
} }
if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'Net_SFTP') { if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'Net_SFTP') {
$this->sftp = $sftp; $this->sftp = $sftp;
return $path; return $path;
} }
if (isset($context['sftp']['username'])) { if (isset($context[$scheme]['username'])) {
$user = $context['sftp']['username']; $user = $context[$scheme]['username'];
} }
if (isset($context['sftp']['password'])) { if (isset($context[$scheme]['password'])) {
$pass = $context['sftp']['password']; $pass = $context[$scheme]['password'];
} }
if (isset($context['sftp']['privkey']) && is_object($context['sftp']['privkey']) && get_Class($context['sftp']['privkey']) == 'Crypt_RSA') { if (isset($context[$scheme]['privkey']) && is_object($context[$scheme]['privkey']) && get_Class($context[$scheme]['privkey']) == 'Crypt_RSA') {
$pass = $context['sftp']['privkey']; $pass = $context[$scheme]['privkey'];
} }
if (!isset($user) || !isset($pass)) { if (!isset($user) || !isset($pass)) {
@ -517,7 +517,20 @@ class Net_SFTP_Stream
* Open directory handle * Open directory handle
* *
* The only $options is "whether or not to enforce safe_mode (0x04)". Since safe mode was deprecated in 5.3 and * The only $options is "whether or not to enforce safe_mode (0x04)". Since safe mode was deprecated in 5.3 and
* removed in 5.4 I'm just going to ignore it * removed in 5.4 I'm just going to ignore it.
*
* Also, nlist() is the best that this function is realistically going to be able to do. When an SFTP client
* sends a SSH_FXP_READDIR packet you don't generally get info on just one file but on multiple files. Quoting
* the SFTP specs:
*
* The SSH_FXP_NAME response has the following format:
*
* uint32 id
* uint32 count
* repeats count times:
* string filename
* string longname
* ATTRS attrs
* *
* @param String $path * @param String $path
* @param Integer $options * @param Integer $options