summaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/icewind/streams/src/Wrapper.php')
-rw-r--r--apps/files_external/3rdparty/icewind/streams/src/Wrapper.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php b/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php
index 8e52eff9a08..babd2c1a0b3 100644
--- a/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php
+++ b/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php
@@ -26,12 +26,15 @@ abstract class Wrapper implements File, Directory {
protected $source;
protected static function wrapSource($source, $context, $protocol, $class) {
+ if (!is_resource($source)) {
+ throw new \BadMethodCallException();
+ }
try {
stream_wrapper_register($protocol, $class);
- if (@rewinddir($source) === false) {
- $wrapped = fopen($protocol . '://', 'r+', false, $context);
- } else {
+ if (self::isDirectoryHandle($source)) {
$wrapped = opendir($protocol . '://', $context);
+ } else {
+ $wrapped = fopen($protocol . '://', 'r+', false, $context);
}
} catch (\BadMethodCallException $e) {
stream_wrapper_unregister($protocol);
@@ -41,6 +44,11 @@ abstract class Wrapper implements File, Directory {
return $wrapped;
}
+ protected static function isDirectoryHandle($resource) {
+ $meta = stream_get_meta_data($resource);
+ return $meta['stream_type'] == 'dir';
+ }
+
/**
* Load the source from the stream context and return the context options
*