nextcloud/apps/files_external/3rdparty/icewind/streams
Robin Appelman c9ecd64d36
update icewind/streams to 0.5.2
Signed-off-by: Robin Appelman <robin@icewind.nl>
2017-01-26 12:19:32 +01:00
..
src update icewind/streams to 0.5.2 2017-01-26 12:19:32 +01:00
.gitignore New SMB storage backend 2015-02-16 13:52:11 +01:00
.travis.yml update icewind/streams to 0.4.0 and icewind/smb to 1.0.7 in files_external 2016-03-21 14:24:00 +01:00
LICENCE update icewind/streams to 0.4.0 and icewind/smb to 1.0.7 in files_external 2016-03-21 14:24:00 +01:00
README.md update icewind/streams to 0.4.0 and icewind/smb to 1.0.7 in files_external 2016-03-21 14:24:00 +01:00
composer.json update icewind/streams to 0.4.0 and icewind/smb to 1.0.7 in files_external 2016-03-21 14:24:00 +01:00

README.md

#Streams#

Build Status Coverage Status Scrutinizer Code Quality

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()