mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
minor native stream cleanup
This commit is contained in:
parent
d218982775
commit
144439d61f
3 changed files with 9 additions and 28 deletions
|
|
@ -38,18 +38,8 @@ class NativeReadStream extends NativeStream {
|
|||
* @param string $url
|
||||
* @return resource
|
||||
*/
|
||||
public static function wrap($state, $smbStream, $mode, $url) {
|
||||
stream_wrapper_register('nativesmb', NativeReadStream::class);
|
||||
$context = stream_context_create([
|
||||
'nativesmb' => [
|
||||
'state' => $state,
|
||||
'handle' => $smbStream,
|
||||
'url' => $url
|
||||
]
|
||||
]);
|
||||
$fh = fopen('nativesmb://', $mode, false, $context);
|
||||
stream_wrapper_unregister('nativesmb');
|
||||
return $fh;
|
||||
public static function wrap(NativeState $state, $smbStream, string $mode, string $url) {
|
||||
return parent::wrapClass($state, $smbStream, $mode, $url, NativeReadStream::class);
|
||||
}
|
||||
|
||||
public function stream_read($count) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Icewind\SMB\Exception\InvalidRequestException;
|
|||
use Icewind\Streams\File;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class NativeStream implements File {
|
||||
abstract class NativeStream implements File {
|
||||
/**
|
||||
* @var resource
|
||||
* @psalm-suppress PropertyNotSetInConstructor
|
||||
|
|
@ -48,10 +48,11 @@ class NativeStream implements File {
|
|||
* @param resource $smbStream
|
||||
* @param string $mode
|
||||
* @param string $url
|
||||
* @param class-string<NativeStream> $class
|
||||
* @return resource
|
||||
*/
|
||||
public static function wrap($state, $smbStream, $mode, $url) {
|
||||
stream_wrapper_register('nativesmb', NativeStream::class);
|
||||
protected static function wrapClass(NativeState $state, $smbStream, string $mode, string $url, string $class) {
|
||||
stream_wrapper_register('nativesmb', $class);
|
||||
$context = stream_context_create([
|
||||
'nativesmb' => [
|
||||
'state' => $state,
|
||||
|
|
|
|||
|
|
@ -38,18 +38,8 @@ class NativeWriteStream extends NativeStream {
|
|||
* @param string $url
|
||||
* @return resource
|
||||
*/
|
||||
public static function wrap($state, $smbStream, $mode, $url) {
|
||||
stream_wrapper_register('nativesmb', NativeWriteStream::class);
|
||||
$context = stream_context_create([
|
||||
'nativesmb' => [
|
||||
'state' => $state,
|
||||
'handle' => $smbStream,
|
||||
'url' => $url
|
||||
]
|
||||
]);
|
||||
$fh = fopen('nativesmb://', $mode, false, $context);
|
||||
stream_wrapper_unregister('nativesmb');
|
||||
return $fh;
|
||||
public static function wrap(NativeState $state, $smbStream, string $mode, string $url) {
|
||||
return parent::wrapClass($state, $smbStream, $mode, $url, NativeWriteStream::class);
|
||||
}
|
||||
|
||||
public function stream_seek($offset, $whence = SEEK_SET) {
|
||||
|
|
@ -66,7 +56,7 @@ class NativeWriteStream extends NativeStream {
|
|||
}
|
||||
|
||||
private function flushWrite(): void {
|
||||
$this->state->write($this->handle, $this->writeBuffer->flush(), $this->url);
|
||||
parent::stream_write($this->writeBuffer->flush());
|
||||
}
|
||||
|
||||
public function stream_write($data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue