mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
Implement the File stream interface
This commit is contained in:
parent
40b6fb8d12
commit
dbc6aa4a9e
3 changed files with 23 additions and 3 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
],
|
],
|
||||||
"require" : {
|
"require" : {
|
||||||
"php": ">=5.3",
|
"php": ">=5.3",
|
||||||
"icewind/streams": "0.1.x"
|
"icewind/streams": "0.2.x"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"satooshi/php-coveralls" : "dev-master"
|
"satooshi/php-coveralls" : "dev-master"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
namespace Icewind\SMB;
|
namespace Icewind\SMB;
|
||||||
|
|
||||||
class NativeStream {
|
use Icewind\Streams\File;
|
||||||
|
|
||||||
|
class NativeStream implements File {
|
||||||
/**
|
/**
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
|
|
@ -55,7 +57,7 @@ class NativeStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function stream_open() {
|
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||||
$context = stream_context_get_options($this->context);
|
$context = stream_context_get_options($this->context);
|
||||||
$this->state = $context['nativesmb']['state'];
|
$this->state = $context['nativesmb']['state'];
|
||||||
$this->handle = $context['nativesmb']['handle'];
|
$this->handle = $context['nativesmb']['handle'];
|
||||||
|
|
@ -85,4 +87,12 @@ class NativeStream {
|
||||||
public function stream_truncate($size) {
|
public function stream_truncate($size) {
|
||||||
return $this->state->ftruncate($this->handle, $size);
|
return $this->state->ftruncate($this->handle, $size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function stream_set_option($option, $arg1, $arg2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stream_lock($operation) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,16 @@ class NativeStream extends \PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals('foo', stream_get_contents($fh));
|
$this->assertEquals('foo', stream_get_contents($fh));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLockUnsupported() {
|
||||||
|
$fh = $this->share->write($this->root . '/foobar');
|
||||||
|
$this->assertFalse(flock($fh, LOCK_SH));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetOptionUnsupported() {
|
||||||
|
$fh = $this->share->write($this->root . '/foobar');
|
||||||
|
$this->assertFalse(stream_set_blocking($fh, false));
|
||||||
|
}
|
||||||
|
|
||||||
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