diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 72d461ea..a148152d 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -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 * diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 4136301e..a892b6f9 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -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; diff --git a/tests/Functional/Net/SFTPLargeFileTest.php b/tests/Functional/Net/SFTPLargeFileTest.php index d661f76a..718426b0 100644 --- a/tests/Functional/Net/SFTPLargeFileTest.php +++ b/tests/Functional/Net/SFTPLargeFileTest.php @@ -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.' ); } diff --git a/tests/Functional/Net/SFTPStreamTest.php b/tests/Functional/Net/SFTPStreamTest.php index aad4189e..e24e85f5 100644 --- a/tests/Functional/Net/SFTPStreamTest.php +++ b/tests/Functional/Net/SFTPStreamTest.php @@ -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')); } /** diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 530e8a25..56c76fe5 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -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; }