mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
Add truncate support to native streams
This commit is contained in:
parent
9068418528
commit
3ae0f3dd0c
2 changed files with 14 additions and 0 deletions
|
|
@ -81,4 +81,8 @@ class NativeStream {
|
|||
public function stream_write($data) {
|
||||
return $this->state->write($this->handle, $data);
|
||||
}
|
||||
|
||||
public function stream_truncate($size) {
|
||||
return $this->state->ftruncate($this->handle, $size);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,16 @@ class NativeStream extends \PHPUnit_Framework_TestCase {
|
|||
unlink($sourceFile);
|
||||
}
|
||||
|
||||
public function testTruncate() {
|
||||
$fh = $this->share->write($this->root . '/foobar');
|
||||
fwrite($fh, 'foobar');
|
||||
ftruncate($fh, 3);
|
||||
fclose($fh);
|
||||
|
||||
$fh = $this->share->read($this->root . '/foobar');
|
||||
$this->assertEquals('foo', stream_get_contents($fh));
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
if ($this->share) {
|
||||
$this->cleanDir($this->root);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue