Update icewind/streams
Fixes #10430 Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
ca54166e35
commit
db4235d587
|
@ -8,7 +8,7 @@
|
||||||
"classmap-authoritative": true
|
"classmap-authoritative": true
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"icewind/streams": "0.5.2",
|
"icewind/streams": "0.6.1",
|
||||||
"icewind/smb": "3.0.0"
|
"icewind/smb": "3.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "0235b6f1a4131c9312afef7a58f3a80e",
|
"content-hash": "1465c8a4b4139e514086d5803d90af2d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "icewind/smb",
|
"name": "icewind/smb",
|
||||||
|
@ -49,16 +49,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "icewind/streams",
|
"name": "icewind/streams",
|
||||||
"version": "0.5.2",
|
"version": "0.6.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/icewind1991/Streams.git",
|
"url": "https://github.com/icewind1991/Streams.git",
|
||||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e"
|
"reference": "0a78597117d8a02937ea05206f219294449fb06e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e",
|
"url": "https://api.github.com/repos/icewind1991/Streams/zipball/0a78597117d8a02937ea05206f219294449fb06e",
|
||||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e",
|
"reference": "0a78597117d8a02937ea05206f219294449fb06e",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "A set of generic stream wrappers",
|
"description": "A set of generic stream wrappers",
|
||||||
"time": "2016-12-02T14:21:23+00:00"
|
"time": "2018-04-24T09:07:38+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
|
|
|
@ -51,14 +51,6 @@ return array(
|
||||||
'Icewind\\SMB\\Native\\NativeWriteStream' => $vendorDir . '/icewind/smb/src/Native/NativeWriteStream.php',
|
'Icewind\\SMB\\Native\\NativeWriteStream' => $vendorDir . '/icewind/smb/src/Native/NativeWriteStream.php',
|
||||||
'Icewind\\SMB\\ServerFactory' => $vendorDir . '/icewind/smb/src/ServerFactory.php',
|
'Icewind\\SMB\\ServerFactory' => $vendorDir . '/icewind/smb/src/ServerFactory.php',
|
||||||
'Icewind\\SMB\\System' => $vendorDir . '/icewind/smb/src/System.php',
|
'Icewind\\SMB\\System' => $vendorDir . '/icewind/smb/src/System.php',
|
||||||
'Icewind\\SMB\\Test\\AbstractShareTest' => $vendorDir . '/icewind/smb/tests/AbstractShareTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\NativeShareTest' => $vendorDir . '/icewind/smb/tests/NativeShareTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\NativeStreamTest' => $vendorDir . '/icewind/smb/tests/NativeStreamTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\NotifyHandlerTest' => $vendorDir . '/icewind/smb/tests/NotifyHandlerTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\ParserTest' => $vendorDir . '/icewind/smb/tests/ParserTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\ServerTest' => $vendorDir . '/icewind/smb/tests/ServerTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\ShareTest' => $vendorDir . '/icewind/smb/tests/ShareTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\TestCase' => $vendorDir . '/icewind/smb/tests/TestCase.php',
|
|
||||||
'Icewind\\SMB\\TimeZoneProvider' => $vendorDir . '/icewind/smb/src/TimeZoneProvider.php',
|
'Icewind\\SMB\\TimeZoneProvider' => $vendorDir . '/icewind/smb/src/TimeZoneProvider.php',
|
||||||
'Icewind\\SMB\\Wrapped\\Connection' => $vendorDir . '/icewind/smb/src/Wrapped/Connection.php',
|
'Icewind\\SMB\\Wrapped\\Connection' => $vendorDir . '/icewind/smb/src/Wrapped/Connection.php',
|
||||||
'Icewind\\SMB\\Wrapped\\ErrorCodes' => $vendorDir . '/icewind/smb/src/Wrapped/ErrorCodes.php',
|
'Icewind\\SMB\\Wrapped\\ErrorCodes' => $vendorDir . '/icewind/smb/src/Wrapped/ErrorCodes.php',
|
||||||
|
@ -69,6 +61,7 @@ return array(
|
||||||
'Icewind\\SMB\\Wrapped\\Server' => $vendorDir . '/icewind/smb/src/Wrapped/Server.php',
|
'Icewind\\SMB\\Wrapped\\Server' => $vendorDir . '/icewind/smb/src/Wrapped/Server.php',
|
||||||
'Icewind\\SMB\\Wrapped\\Share' => $vendorDir . '/icewind/smb/src/Wrapped/Share.php',
|
'Icewind\\SMB\\Wrapped\\Share' => $vendorDir . '/icewind/smb/src/Wrapped/Share.php',
|
||||||
'Icewind\\Streams\\CallbackWrapper' => $vendorDir . '/icewind/streams/src/CallbackWrapper.php',
|
'Icewind\\Streams\\CallbackWrapper' => $vendorDir . '/icewind/streams/src/CallbackWrapper.php',
|
||||||
|
'Icewind\\Streams\\CountWrapper' => $vendorDir . '/icewind/streams/src/CountWrapper.php',
|
||||||
'Icewind\\Streams\\Directory' => $vendorDir . '/icewind/streams/src/Directory.php',
|
'Icewind\\Streams\\Directory' => $vendorDir . '/icewind/streams/src/Directory.php',
|
||||||
'Icewind\\Streams\\DirectoryFilter' => $vendorDir . '/icewind/streams/src/DirectoryFilter.php',
|
'Icewind\\Streams\\DirectoryFilter' => $vendorDir . '/icewind/streams/src/DirectoryFilter.php',
|
||||||
'Icewind\\Streams\\DirectoryWrapper' => $vendorDir . '/icewind/streams/src/DirectoryWrapper.php',
|
'Icewind\\Streams\\DirectoryWrapper' => $vendorDir . '/icewind/streams/src/DirectoryWrapper.php',
|
||||||
|
|
|
@ -81,14 +81,6 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
|
||||||
'Icewind\\SMB\\Native\\NativeWriteStream' => __DIR__ . '/..' . '/icewind/smb/src/Native/NativeWriteStream.php',
|
'Icewind\\SMB\\Native\\NativeWriteStream' => __DIR__ . '/..' . '/icewind/smb/src/Native/NativeWriteStream.php',
|
||||||
'Icewind\\SMB\\ServerFactory' => __DIR__ . '/..' . '/icewind/smb/src/ServerFactory.php',
|
'Icewind\\SMB\\ServerFactory' => __DIR__ . '/..' . '/icewind/smb/src/ServerFactory.php',
|
||||||
'Icewind\\SMB\\System' => __DIR__ . '/..' . '/icewind/smb/src/System.php',
|
'Icewind\\SMB\\System' => __DIR__ . '/..' . '/icewind/smb/src/System.php',
|
||||||
'Icewind\\SMB\\Test\\AbstractShareTest' => __DIR__ . '/..' . '/icewind/smb/tests/AbstractShareTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\NativeShareTest' => __DIR__ . '/..' . '/icewind/smb/tests/NativeShareTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\NativeStreamTest' => __DIR__ . '/..' . '/icewind/smb/tests/NativeStreamTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\NotifyHandlerTest' => __DIR__ . '/..' . '/icewind/smb/tests/NotifyHandlerTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\ParserTest' => __DIR__ . '/..' . '/icewind/smb/tests/ParserTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\ServerTest' => __DIR__ . '/..' . '/icewind/smb/tests/ServerTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\ShareTest' => __DIR__ . '/..' . '/icewind/smb/tests/ShareTest.php',
|
|
||||||
'Icewind\\SMB\\Test\\TestCase' => __DIR__ . '/..' . '/icewind/smb/tests/TestCase.php',
|
|
||||||
'Icewind\\SMB\\TimeZoneProvider' => __DIR__ . '/..' . '/icewind/smb/src/TimeZoneProvider.php',
|
'Icewind\\SMB\\TimeZoneProvider' => __DIR__ . '/..' . '/icewind/smb/src/TimeZoneProvider.php',
|
||||||
'Icewind\\SMB\\Wrapped\\Connection' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/Connection.php',
|
'Icewind\\SMB\\Wrapped\\Connection' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/Connection.php',
|
||||||
'Icewind\\SMB\\Wrapped\\ErrorCodes' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/ErrorCodes.php',
|
'Icewind\\SMB\\Wrapped\\ErrorCodes' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/ErrorCodes.php',
|
||||||
|
@ -99,6 +91,7 @@ class ComposerStaticInit98fe9b281934250b3a93f69a5ce843b3
|
||||||
'Icewind\\SMB\\Wrapped\\Server' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/Server.php',
|
'Icewind\\SMB\\Wrapped\\Server' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/Server.php',
|
||||||
'Icewind\\SMB\\Wrapped\\Share' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/Share.php',
|
'Icewind\\SMB\\Wrapped\\Share' => __DIR__ . '/..' . '/icewind/smb/src/Wrapped/Share.php',
|
||||||
'Icewind\\Streams\\CallbackWrapper' => __DIR__ . '/..' . '/icewind/streams/src/CallbackWrapper.php',
|
'Icewind\\Streams\\CallbackWrapper' => __DIR__ . '/..' . '/icewind/streams/src/CallbackWrapper.php',
|
||||||
|
'Icewind\\Streams\\CountWrapper' => __DIR__ . '/..' . '/icewind/streams/src/CountWrapper.php',
|
||||||
'Icewind\\Streams\\Directory' => __DIR__ . '/..' . '/icewind/streams/src/Directory.php',
|
'Icewind\\Streams\\Directory' => __DIR__ . '/..' . '/icewind/streams/src/Directory.php',
|
||||||
'Icewind\\Streams\\DirectoryFilter' => __DIR__ . '/..' . '/icewind/streams/src/DirectoryFilter.php',
|
'Icewind\\Streams\\DirectoryFilter' => __DIR__ . '/..' . '/icewind/streams/src/DirectoryFilter.php',
|
||||||
'Icewind\\Streams\\DirectoryWrapper' => __DIR__ . '/..' . '/icewind/streams/src/DirectoryWrapper.php',
|
'Icewind\\Streams\\DirectoryWrapper' => __DIR__ . '/..' . '/icewind/streams/src/DirectoryWrapper.php',
|
||||||
|
|
|
@ -44,17 +44,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "icewind/streams",
|
"name": "icewind/streams",
|
||||||
"version": "0.5.2",
|
"version": "0.6.1",
|
||||||
"version_normalized": "0.5.2.0",
|
"version_normalized": "0.6.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/icewind1991/Streams.git",
|
"url": "https://github.com/icewind1991/Streams.git",
|
||||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e"
|
"reference": "0a78597117d8a02937ea05206f219294449fb06e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e",
|
"url": "https://api.github.com/repos/icewind1991/Streams/zipball/0a78597117d8a02937ea05206f219294449fb06e",
|
||||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e",
|
"reference": "0a78597117d8a02937ea05206f219294449fb06e",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
"phpunit/phpunit": "^4.8",
|
"phpunit/phpunit": "^4.8",
|
||||||
"satooshi/php-coveralls": "v1.0.0"
|
"satooshi/php-coveralls": "v1.0.0"
|
||||||
},
|
},
|
||||||
"time": "2016-12-02T14:21:23+00:00",
|
"time": "2018-04-24T09:07:38+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"installation-source": "dist",
|
"installation-source": "dist",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
|
@ -4,11 +4,8 @@ php:
|
||||||
- 5.5
|
- 5.5
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- hhvm
|
- 7.1
|
||||||
|
- 7.2
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- php: hhvm # due to facebook/hhvm#3321
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#Streams#
|
# Streams #
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/icewind1991/Streams.svg?branch=master)](https://travis-ci.org/icewind1991/Streams)
|
[![Build Status](https://travis-ci.org/icewind1991/Streams.svg?branch=master)](https://travis-ci.org/icewind1991/Streams)
|
||||||
[![Coverage Status](https://img.shields.io/coveralls/icewind1991/Streams.svg)](https://coveralls.io/r/icewind1991/Streams?branch=master)
|
[![Coverage Status](https://img.shields.io/coveralls/icewind1991/Streams.svg)](https://coveralls.io/r/icewind1991/Streams?branch=master)
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
Generic stream wrappers for php.
|
Generic stream wrappers for php.
|
||||||
|
|
||||||
##CallBackWrapper##
|
## CallBackWrapper ##
|
||||||
|
|
||||||
A `CallBackWrapper` can be used to register callbacks on read, write and closing of the stream,
|
A `CallBackWrapper` can be used to register callbacks on read, write and closing of the stream,
|
||||||
it wraps an existing stream and can thus be used for any stream in php
|
it wraps an existing stream and can thus be used for any stream in php
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Icewind\Streams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper that counts the amount of data read and written
|
||||||
|
*
|
||||||
|
* The following options should be passed in the context when opening the stream
|
||||||
|
* [
|
||||||
|
* 'callback' => [
|
||||||
|
* 'source' => resource
|
||||||
|
* 'callback' => function($readCount, $writeCount){}
|
||||||
|
* ]
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* The callback will be called when the stream is closed
|
||||||
|
*/
|
||||||
|
class CountWrapper extends Wrapper {
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $readCount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $writeCount = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var callable
|
||||||
|
*/
|
||||||
|
protected $callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a stream with the provided callbacks
|
||||||
|
*
|
||||||
|
* @param resource $source
|
||||||
|
* @param callable $callback
|
||||||
|
* @return resource
|
||||||
|
*
|
||||||
|
* @throws \BadMethodCallException
|
||||||
|
*/
|
||||||
|
public static function wrap($source, $callback) {
|
||||||
|
if (!is_callable($callback)) {
|
||||||
|
throw new \InvalidArgumentException('Invalid or missing callback');
|
||||||
|
}
|
||||||
|
$context = stream_context_create(array(
|
||||||
|
'count' => array(
|
||||||
|
'source' => $source,
|
||||||
|
'callback' => $callback
|
||||||
|
)
|
||||||
|
));
|
||||||
|
return Wrapper::wrapSource($source, $context, 'callback', '\Icewind\Streams\CountWrapper');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function open() {
|
||||||
|
$context = $this->loadContext('count');
|
||||||
|
$this->callback = $context['callback'];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dir_opendir($path, $options) {
|
||||||
|
return $this->open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||||
|
return $this->open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stream_read($count) {
|
||||||
|
$result = parent::stream_read($count);
|
||||||
|
$this->readCount += strlen($result);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stream_write($data) {
|
||||||
|
$result = parent::stream_write($data);
|
||||||
|
$this->writeCount += strlen($data);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stream_close() {
|
||||||
|
$result = parent::stream_close();
|
||||||
|
call_user_func($this->callback, $this->readCount, $this->writeCount);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,12 +26,15 @@ abstract class Wrapper implements File, Directory {
|
||||||
protected $source;
|
protected $source;
|
||||||
|
|
||||||
protected static function wrapSource($source, $context, $protocol, $class) {
|
protected static function wrapSource($source, $context, $protocol, $class) {
|
||||||
|
if (!is_resource($source)) {
|
||||||
|
throw new \BadMethodCallException();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
stream_wrapper_register($protocol, $class);
|
stream_wrapper_register($protocol, $class);
|
||||||
if (@rewinddir($source) === false) {
|
if (self::isDirectoryHandle($source)) {
|
||||||
$wrapped = fopen($protocol . '://', 'r+', false, $context);
|
|
||||||
} else {
|
|
||||||
$wrapped = opendir($protocol . '://', $context);
|
$wrapped = opendir($protocol . '://', $context);
|
||||||
|
} else {
|
||||||
|
$wrapped = fopen($protocol . '://', 'r+', false, $context);
|
||||||
}
|
}
|
||||||
} catch (\BadMethodCallException $e) {
|
} catch (\BadMethodCallException $e) {
|
||||||
stream_wrapper_unregister($protocol);
|
stream_wrapper_unregister($protocol);
|
||||||
|
@ -41,6 +44,11 @@ abstract class Wrapper implements File, Directory {
|
||||||
return $wrapped;
|
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
|
* Load the source from the stream context and return the context options
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue