SFTP: rm size() (we already have filesize())

This commit is contained in:
terrafrost 2020-02-11 23:01:18 -06:00
parent b95120c808
commit 8dac275a03
5 changed files with 8 additions and 30 deletions

View File

@ -1060,28 +1060,6 @@ class SFTP extends SSH2
}
}
/**
* Returns the file size, in bytes, or false, on failure
*
* Files larger than 4GB will show up as being exactly 4GB.
*
* @param string $filename
* @return mixed
* @access public
*/
public function size($filename)
{
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
return false;
}
$result = $this->stat($filename);
if ($result === false) {
return false;
}
return isset($result['size']) ? $result['size'] : -1;
}
/**
* Save files / directories to cache
*

View File

@ -266,7 +266,7 @@ class Stream
}
$this->path = $path;
$this->size = $this->sftp->size($path);
$this->size = $this->sftp->filesize($path);
$this->mode = preg_replace('#[bt]$#', '', $mode);
$this->eof = false;

View File

@ -36,7 +36,7 @@ class Functional_Net_SFTPLargeFileTest extends Functional_Net_SFTPTestCase
$this->assertSame(
128 * 1024 * 1024,
$this->sftp->size($filename),
$this->sftp->filesize($filename),
'Failed asserting that uploaded local file has the expected length.'
);
}

View File

@ -24,7 +24,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
$fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context);
$this->assertInternalType('resource', $fp);
fclose($fp);
$this->assertSame(0, $this->sftp->size('fooo.txt'));
$this->assertSame(0, $this->sftp->filesize('fooo.txt'));
}
/**

View File

@ -148,7 +148,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$this->assertSame(
self::$exampleDataLength,
$sftp->size('file1.txt'),
$sftp->filesize('file1.txt'),
'Failed asserting that put example data has the expected length'
);
@ -184,7 +184,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$this->assertSame(
self::$exampleDataLength,
$sftp->size('file1.txt'),
$sftp->filesize('file1.txt'),
'Failed asserting that put example data has the expected length'
);
@ -232,7 +232,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$this->assertSame(
1024 * 1024,
$sftp->size('file3.txt'),
$sftp->filesize('file3.txt'),
'Failed asserting that truncate()\'d file has the expected length'
);
@ -352,7 +352,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$last_size = 0x7FFFFFFF;
foreach ($files as $file) {
if ($sftp->is_file($file)) {
$cur_size = $sftp->size($file);
$cur_size = $sftp->filesize($file);
$this->assertLessThanOrEqual(
$last_size,
$cur_size,
@ -547,7 +547,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$filename = 'file-large-from-truncate-4112MiB.txt';
$this->assertTrue($sftp->touch($filename));
$this->assertTrue($sftp->truncate($filename, $filesize));
$this->assertSame($filesize, $sftp->size($filename));
$this->assertSame($filesize, $sftp->filesize($filename));
return $sftp;
}