mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +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) {
|
public function stream_write($data) {
|
||||||
return $this->state->write($this->handle, $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);
|
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() {
|
public function tearDown() {
|
||||||
if ($this->share) {
|
if ($this->share) {
|
||||||
$this->cleanDir($this->root);
|
$this->cleanDir($this->root);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue