mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 02:07:09 +00:00
Merge branch '3.0'
This commit is contained in:
commit
c1d2ebf770
@ -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
|
* Save files / directories to cache
|
||||||
*
|
*
|
||||||
|
@ -266,7 +266,7 @@ class Stream
|
|||||||
}
|
}
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
|
||||||
$this->size = $this->sftp->size($path);
|
$this->size = $this->sftp->filesize($path);
|
||||||
$this->mode = preg_replace('#[bt]$#', '', $mode);
|
$this->mode = preg_replace('#[bt]$#', '', $mode);
|
||||||
$this->eof = false;
|
$this->eof = false;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class Functional_Net_SFTPLargeFileTest extends Functional_Net_SFTPTestCase
|
|||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
128 * 1024 * 1024,
|
128 * 1024 * 1024,
|
||||||
$this->sftp->size($filename),
|
$this->sftp->filesize($filename),
|
||||||
'Failed asserting that uploaded local file has the expected length.'
|
'Failed asserting that uploaded local file has the expected length.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
|
|||||||
$fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context);
|
$fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context);
|
||||||
$this->assertInternalType('resource', $fp);
|
$this->assertInternalType('resource', $fp);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
$this->assertSame(0, $this->sftp->size('fooo.txt'));
|
$this->assertSame(0, $this->sftp->filesize('fooo.txt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +148,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
self::$exampleDataLength,
|
self::$exampleDataLength,
|
||||||
$sftp->size('file1.txt'),
|
$sftp->filesize('file1.txt'),
|
||||||
'Failed asserting that put example data has the expected length'
|
'Failed asserting that put example data has the expected length'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
self::$exampleDataLength,
|
self::$exampleDataLength,
|
||||||
$sftp->size('file1.txt'),
|
$sftp->filesize('file1.txt'),
|
||||||
'Failed asserting that put example data has the expected length'
|
'Failed asserting that put example data has the expected length'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
1024 * 1024,
|
1024 * 1024,
|
||||||
$sftp->size('file3.txt'),
|
$sftp->filesize('file3.txt'),
|
||||||
'Failed asserting that truncate()\'d file has the expected length'
|
'Failed asserting that truncate()\'d file has the expected length'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -352,7 +352,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
$last_size = 0x7FFFFFFF;
|
$last_size = 0x7FFFFFFF;
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if ($sftp->is_file($file)) {
|
if ($sftp->is_file($file)) {
|
||||||
$cur_size = $sftp->size($file);
|
$cur_size = $sftp->filesize($file);
|
||||||
$this->assertLessThanOrEqual(
|
$this->assertLessThanOrEqual(
|
||||||
$last_size,
|
$last_size,
|
||||||
$cur_size,
|
$cur_size,
|
||||||
@ -547,7 +547,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
$filename = 'file-large-from-truncate-4112MiB.txt';
|
$filename = 'file-large-from-truncate-4112MiB.txt';
|
||||||
$this->assertTrue($sftp->touch($filename));
|
$this->assertTrue($sftp->touch($filename));
|
||||||
$this->assertTrue($sftp->truncate($filename, $filesize));
|
$this->assertTrue($sftp->truncate($filename, $filesize));
|
||||||
$this->assertSame($filesize, $sftp->size($filename));
|
$this->assertSame($filesize, $sftp->filesize($filename));
|
||||||
|
|
||||||
return $sftp;
|
return $sftp;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user