Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-03-10 17:31:09 +0300
committerRobin Appelman <robin@icewind.nl>2021-03-10 17:31:09 +0300
commit66781e74ada3fd22bb5b246a59897ac146cda4dd (patch)
treeddb35b074eb6523c1aaffb68e78f58faf797ae23 /apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php
parent62929cc646134fbd409cfb4eacb7039d15763b96 (diff)
update icewind/smb to 3.4.0
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php')
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php48
1 files changed, 36 insertions, 12 deletions
diff --git a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php
index c75afaa5f1d..216c27f78e3 100644
--- a/apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php
+++ b/apps/files_external/3rdparty/icewind/smb/src/Native/NativeStream.php
@@ -10,20 +10,24 @@ namespace Icewind\SMB\Native;
use Icewind\SMB\Exception\Exception;
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
*/
public $context;
/**
* @var NativeState
+ * @psalm-suppress PropertyNotSetInConstructor
*/
protected $state;
/**
* @var resource
+ * @psalm-suppress PropertyNotSetInConstructor
*/
protected $handle;
@@ -35,19 +39,20 @@ class NativeStream implements File {
/**
* @var string
*/
- protected $url;
+ protected $url = '';
/**
* Wrap a stream from libsmbclient-php into a regular php stream
*
- * @param \Icewind\SMB\NativeState $state
+ * @param NativeState $state
* @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,
@@ -73,19 +78,35 @@ class NativeStream implements File {
}
public function stream_flush() {
+ return false;
}
public function stream_open($path, $mode, $options, &$opened_path) {
$context = stream_context_get_options($this->context);
- $this->state = $context['nativesmb']['state'];
- $this->handle = $context['nativesmb']['handle'];
- $this->url = $context['nativesmb']['url'];
+ if (!isset($context['nativesmb']) || !is_array($context['nativesmb'])) {
+ throw new InvalidArgumentException("context not set");
+ }
+ $state = $context['nativesmb']['state'];
+ if (!$state instanceof NativeState) {
+ throw new InvalidArgumentException("invalid context set");
+ }
+ $this->state = $state;
+ $handle = $context['nativesmb']['handle'];
+ if (!is_resource($handle)) {
+ throw new InvalidArgumentException("invalid context set");
+ }
+ $this->handle = $handle;
+ $url = $context['nativesmb']['url'];
+ if (!is_string($url)) {
+ throw new InvalidArgumentException("invalid context set");
+ }
+ $this->url = $url;
return true;
}
public function stream_read($count) {
- $result = $this->state->read($this->handle, $count);
+ $result = $this->state->read($this->handle, $count, $this->url);
if (strlen($result) < $count) {
$this->eof = true;
}
@@ -95,12 +116,15 @@ class NativeStream implements File {
public function stream_seek($offset, $whence = SEEK_SET) {
$this->eof = false;
try {
- return $this->state->lseek($this->handle, $offset, $whence) !== false;
+ return $this->state->lseek($this->handle, $offset, $whence, $this->url) !== false;
} catch (InvalidRequestException $e) {
return false;
}
}
+ /**
+ * @return array{"mtime": int, "size": int, "mode": int}|false
+ */
public function stream_stat() {
try {
return $this->state->stat($this->url);
@@ -110,7 +134,7 @@ class NativeStream implements File {
}
public function stream_tell() {
- return $this->state->lseek($this->handle, 0, SEEK_CUR);
+ return $this->state->lseek($this->handle, 0, SEEK_CUR, $this->url);
}
public function stream_write($data) {
@@ -118,7 +142,7 @@ class NativeStream implements File {
}
public function stream_truncate($size) {
- return $this->state->ftruncate($this->handle, $size);
+ return $this->state->ftruncate($this->handle, $size, $this->url);
}
public function stream_set_option($option, $arg1, $arg2) {