0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-08 07:40:46 +00:00
nextcloud_server/apps/files_external/3rdparty/icewind/streams
Côme Chilliet 1a12f14a19
Update icewind/streams to 0.7.7, and remove it from explicit deps in files_external
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2023-05-11 12:05:12 +02:00
..
src Update icewind/streams to 0.7.7, and remove it from explicit deps in files_external 2023-05-11 12:05:12 +02:00
.gitignore update icewind/smb to 3.4.0 2021-03-10 15:31:09 +01:00
composer.json update icewind/smb to 3.4.0 2021-03-10 15:31:09 +01:00
LICENCE
README.md update icewind/smb to 3.4.0 2021-03-10 15:31:09 +01:00

Streams

CI codecov

Generic stream wrappers for php.

CallBackWrapper

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

The callbacks are passed in the stream context along with the source stream and can be any valid php callable

Example

<?php

use \Icewind\Streams\CallBackWrapper;

require('vendor/autoload.php');

// get an existing stream to wrap
$source = fopen('php://temp', 'r+');

// register the callbacks
$stream = CallbackWrapper::wrap($source,
	// read callback
	function ($count) {
		echo "read " . $count . "bytes\n";
	},
	// write callback
	function ($data) {
		echo "wrote '" . $data . "'\n";
	},
	// close callback
	function () {
		echo "stream closed\n";
	});

fwrite($stream, 'some dummy data');

rewind($stream);
fread($stream, 5);

fclose($stream);

Note: due to php's internal stream buffering the $count passed to the read callback will be equal to php's internal buffer size (8192 on default) an not the number of bytes requested by fopen()