mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-12 16:36:30 +00:00
Merge branch '3.0'
This commit is contained in:
commit
501c96c48c
@ -2490,12 +2490,31 @@ class SFTP extends SSH2
|
||||
return $this->get_stat_cache_prop($path, 'gid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively go through rawlist() output to get the total filesize
|
||||
*/
|
||||
private static function recursiveFilesize(array $files): int
|
||||
{
|
||||
$size = 0;
|
||||
foreach ($files as $name => $file) {
|
||||
if ($name == '.' || $name == '..') {
|
||||
continue;
|
||||
}
|
||||
$size += is_array($file) ?
|
||||
self::recursiveFilesize($file) :
|
||||
$file->size;
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets file size
|
||||
*/
|
||||
public function filesize(string $path)
|
||||
public function filesize(string $path, bool $recursive = false)
|
||||
{
|
||||
return $this->get_stat_cache_prop($path, 'size');
|
||||
return !$recursive || $this->filetype($path) != 'dir' ?
|
||||
$this->get_stat_cache_prop($path, 'size') :
|
||||
$this->recursiveFilesize($this->rawlist($path, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,7 +257,7 @@ zUlir0ACPypC1Q==
|
||||
$this->assertSame($data, $decrypted);
|
||||
}
|
||||
|
||||
public function testSettingOnePadding()
|
||||
public function testSettingOnePadding(): void
|
||||
{
|
||||
$pub = <<<HERE
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
|
Loading…
Reference in New Issue
Block a user