mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
Error handling in NativeStream
This commit is contained in:
parent
889342b63c
commit
fdb606257d
3 changed files with 17 additions and 11 deletions
|
|
@ -24,9 +24,6 @@ class NativeServer extends Server {
|
|||
}
|
||||
|
||||
protected function connect() {
|
||||
if ($this->state and is_resource($this->state)) {
|
||||
return;
|
||||
}
|
||||
$user = $this->getUser();
|
||||
$workgroup = null;
|
||||
if (strpos($user, '/')) {
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ class NativeShare implements IShare {
|
|||
public function read($source) {
|
||||
$this->connect();
|
||||
$handle = $this->state->open($this->buildUrl($source), 'r');
|
||||
return NativeStream::wrap($this->state->getState(), $handle, 'r');
|
||||
return NativeStream::wrap($this->state, $handle, 'r');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -237,7 +237,7 @@ class NativeShare implements IShare {
|
|||
public function write($source) {
|
||||
$this->connect();
|
||||
$handle = $this->state->create($this->buildUrl($source));
|
||||
return NativeStream::wrap($this->state->getState(), $handle, 'w');
|
||||
return NativeStream::wrap($this->state, $handle, 'w');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,16 +8,25 @@
|
|||
namespace Icewind\SMB;
|
||||
|
||||
class NativeStream {
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
public $context;
|
||||
|
||||
/**
|
||||
* @var \Icewind\SMB\NativeState
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $handle;
|
||||
|
||||
/**
|
||||
* Wrap a stream from libsmbclient-php into a regular php stream
|
||||
*
|
||||
* @param resource $state
|
||||
* @param \Icewind\SMB\NativeState $state
|
||||
* @param resource $smbStream
|
||||
* @param string $mode
|
||||
* @return resource
|
||||
|
|
@ -36,7 +45,7 @@ class NativeStream {
|
|||
}
|
||||
|
||||
public function stream_close() {
|
||||
return smbclient_close($this->state, $this->handle);
|
||||
return $this->state->close($this->handle);
|
||||
}
|
||||
|
||||
public function stream_eof() {
|
||||
|
|
@ -54,15 +63,15 @@ class NativeStream {
|
|||
}
|
||||
|
||||
public function stream_read($count) {
|
||||
return smbclient_read($this->state, $this->handle, $count);
|
||||
return $this->state->read($this->handle, $count);
|
||||
}
|
||||
|
||||
public function stream_seek($offset, $whence = SEEK_SET) {
|
||||
return smbclient_lseek($this->state, $this->handle, $offset, $whence);
|
||||
return $this->state->lseek($this->handle, $offset, $whence);
|
||||
}
|
||||
|
||||
public function stream_stat() {
|
||||
return smbclient_fstat($this->state, $this->handle);
|
||||
return $this->state->fstat($this->handle);
|
||||
}
|
||||
|
||||
public function stream_tell() {
|
||||
|
|
@ -70,6 +79,6 @@ class NativeStream {
|
|||
}
|
||||
|
||||
public function stream_write($data) {
|
||||
return smbclient_write($this->state, $this->handle, $data);
|
||||
return $this->state->write($this->handle, $data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue