mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-28 17:48:35 +00:00
Merge branch '3.0'
This commit is contained in:
commit
7364fc54e5
@ -3231,6 +3231,8 @@ class SFTP extends SSH2
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* POSIX Rename
|
||||||
|
*
|
||||||
* Where rename() fails "if there already exists a file with the name specified by newpath"
|
* Where rename() fails "if there already exists a file with the name specified by newpath"
|
||||||
* (draft-ietf-secsh-filexfer-02#section-6.5), posix_rename() overwrites the existing file in an atomic fashion.
|
* (draft-ietf-secsh-filexfer-02#section-6.5), posix_rename() overwrites the existing file in an atomic fashion.
|
||||||
* ie. "there is no observable instant in time where the name does not refer to either the old or the new file"
|
* ie. "there is no observable instant in time where the name does not refer to either the old or the new file"
|
||||||
@ -3241,8 +3243,12 @@ class SFTP extends SSH2
|
|||||||
if (!$this->precheck()) {
|
if (!$this->precheck()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->extensions['posix-rename@openssh.com']) || $this->extensions['posix-rename@openssh.com'] !== '1') {
|
if (!isset($this->extensions['posix-rename@openssh.com']) || $this->extensions['posix-rename@openssh.com'] !== '1') {
|
||||||
throw new \RuntimeException("Extension 'posix-rename@openssh.com' is not supported by the server");
|
throw new RuntimeException(
|
||||||
|
"Extension 'posix-rename@openssh.com' is not supported by the server. " .
|
||||||
|
"Call getSupportedVersions() to see a list of supported extension"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldname = $this->realpath($oldname);
|
$oldname = $this->realpath($oldname);
|
||||||
@ -3256,9 +3262,9 @@ class SFTP extends SSH2
|
|||||||
|
|
||||||
$response = $this->get_sftp_packet();
|
$response = $this->get_sftp_packet();
|
||||||
if ($this->packet_type != PacketType::STATUS) {
|
if ($this->packet_type != PacketType::STATUS) {
|
||||||
throw new \UnexpectedValueException(
|
throw new UnexpectedValueException(
|
||||||
'Expected NET_SFTP_STATUS. '
|
'Expected NET_SFTP_STATUS. ' .
|
||||||
. 'Got packet type: ' . $this->packet_type
|
'Got packet type: ' . $this->packet_type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3279,6 +3285,8 @@ class SFTP extends SSH2
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns general information about a file system.
|
||||||
|
*
|
||||||
* The function statvfs() returns information about a mounted filesystem.
|
* The function statvfs() returns information about a mounted filesystem.
|
||||||
* @see https://man7.org/linux/man-pages/man3/statvfs.3.html
|
* @see https://man7.org/linux/man-pages/man3/statvfs.3.html
|
||||||
*
|
*
|
||||||
@ -3286,8 +3294,15 @@ class SFTP extends SSH2
|
|||||||
*/
|
*/
|
||||||
public function statvfs(string $path): array|bool
|
public function statvfs(string $path): array|bool
|
||||||
{
|
{
|
||||||
|
if (!$this->precheck()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($this->extensions['statvfs@openssh.com']) || $this->extensions['statvfs@openssh.com'] !== '2') {
|
if (!isset($this->extensions['statvfs@openssh.com']) || $this->extensions['statvfs@openssh.com'] !== '2') {
|
||||||
throw new \RuntimeException("Extension 'statvfs@openssh.com' is not supported by the server");
|
throw new RuntimeException(
|
||||||
|
"Extension 'statvfs@openssh.com' is not supported by the server. " .
|
||||||
|
"Call getSupportedVersions() to see a list of supported extension"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$realpath = $this->realpath($path);
|
$realpath = $this->realpath($path);
|
||||||
@ -3300,9 +3315,9 @@ class SFTP extends SSH2
|
|||||||
|
|
||||||
$response = $this->get_sftp_packet();
|
$response = $this->get_sftp_packet();
|
||||||
if ($this->packet_type !== PacketType::EXTENDED_REPLY) {
|
if ($this->packet_type !== PacketType::EXTENDED_REPLY) {
|
||||||
throw new \UnexpectedValueException(
|
throw new UnexpectedValueException(
|
||||||
'Expected SSH_FXP_EXTENDED_REPLY. '
|
'Expected SSH_FXP_EXTENDED_REPLY. ' .
|
||||||
. 'Got packet type: ' . $this->packet_type
|
'Got packet type: ' . $this->packet_type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user