update icewind/smb to 2.0.2tags/v13.0.0beta1
icewind/smb/tests | icewind/smb/tests | ||||
icewind/smb/install_libsmbclient.sh | icewind/smb/install_libsmbclient.sh | ||||
icewind/smb/.travis.yml | icewind/smb/.travis.yml | ||||
icewind/smb/.scrutinizer.yml | |||||
icewind/streams/tests | icewind/streams/tests |
"classmap-authoritative": true | "classmap-authoritative": true | ||||
}, | }, | ||||
"require": { | "require": { | ||||
"icewind/smb": "2.0.0", | |||||
"icewind/smb": "2.0.2", | |||||
"icewind/streams": "0.5.2" | "icewind/streams": "0.5.2" | ||||
} | } | ||||
} | } |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | ||||
"This file is @generated automatically" | "This file is @generated automatically" | ||||
], | ], | ||||
"content-hash": "0bbca3fe2d180fbc5681985bdf6b22e7", | |||||
"content-hash": "85f8c3519f909ded38d917d3901f2709", | |||||
"packages": [ | "packages": [ | ||||
{ | { | ||||
"name": "icewind/smb", | "name": "icewind/smb", | ||||
"version": "v2.0.0", | |||||
"version": "v2.0.2", | |||||
"source": { | "source": { | ||||
"type": "git", | "type": "git", | ||||
"url": "https://github.com/icewind1991/SMB.git", | "url": "https://github.com/icewind1991/SMB.git", | ||||
"reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a" | |||||
"reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0" | |||||
}, | }, | ||||
"dist": { | "dist": { | ||||
"type": "zip", | "type": "zip", | ||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", | |||||
"reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", | |||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", | |||||
"reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", | |||||
"shasum": "" | "shasum": "" | ||||
}, | }, | ||||
"require": { | "require": { | ||||
} | } | ||||
], | ], | ||||
"description": "php wrapper for smbclient and libsmbclient-php", | "description": "php wrapper for smbclient and libsmbclient-php", | ||||
"time": "2016-12-13T13:56:55+00:00" | |||||
"time": "2017-08-16T16:08:57+00:00" | |||||
}, | }, | ||||
{ | { | ||||
"name": "icewind/streams", | "name": "icewind/streams", |
$first = $class[0]; | $first = $class[0]; | ||||
if (isset($this->prefixLengthsPsr4[$first])) { | if (isset($this->prefixLengthsPsr4[$first])) { | ||||
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { | |||||
if (0 === strpos($class, $prefix)) { | |||||
foreach ($this->prefixDirsPsr4[$prefix] as $dir) { | |||||
$subPath = $class; | |||||
while (false !== $lastPos = strrpos($subPath, '\\')) { | |||||
$subPath = substr($subPath, 0, $lastPos); | |||||
$search = $subPath.'\\'; | |||||
if (isset($this->prefixDirsPsr4[$search])) { | |||||
foreach ($this->prefixDirsPsr4[$search] as $dir) { | |||||
$length = $this->prefixLengthsPsr4[$first][$search]; | |||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { | ||||
return $file; | return $file; | ||||
} | } |
Copyright (c) 2016 Nils Adermann, Jordi Boggiano | |||||
Copyright (c) Nils Adermann, Jordi Boggiano | |||||
Permission is hereby granted, free of charge, to any person obtaining a copy | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
of this software and associated documentation files (the "Software"), to deal | of this software and associated documentation files (the "Software"), to deal |
'Icewind\\SMB\\INotifyHandler' => $vendorDir . '/icewind/smb/src/INotifyHandler.php', | 'Icewind\\SMB\\INotifyHandler' => $vendorDir . '/icewind/smb/src/INotifyHandler.php', | ||||
'Icewind\\SMB\\IShare' => $vendorDir . '/icewind/smb/src/IShare.php', | 'Icewind\\SMB\\IShare' => $vendorDir . '/icewind/smb/src/IShare.php', | ||||
'Icewind\\SMB\\NativeFileInfo' => $vendorDir . '/icewind/smb/src/NativeFileInfo.php', | 'Icewind\\SMB\\NativeFileInfo' => $vendorDir . '/icewind/smb/src/NativeFileInfo.php', | ||||
'Icewind\\SMB\\NativeReadStream' => $vendorDir . '/icewind/smb/src/NativeReadStream.php', | |||||
'Icewind\\SMB\\NativeServer' => $vendorDir . '/icewind/smb/src/NativeServer.php', | 'Icewind\\SMB\\NativeServer' => $vendorDir . '/icewind/smb/src/NativeServer.php', | ||||
'Icewind\\SMB\\NativeShare' => $vendorDir . '/icewind/smb/src/NativeShare.php', | 'Icewind\\SMB\\NativeShare' => $vendorDir . '/icewind/smb/src/NativeShare.php', | ||||
'Icewind\\SMB\\NativeState' => $vendorDir . '/icewind/smb/src/NativeState.php', | 'Icewind\\SMB\\NativeState' => $vendorDir . '/icewind/smb/src/NativeState.php', | ||||
'Icewind\\SMB\\NativeStream' => $vendorDir . '/icewind/smb/src/NativeStream.php', | 'Icewind\\SMB\\NativeStream' => $vendorDir . '/icewind/smb/src/NativeStream.php', | ||||
'Icewind\\SMB\\NativeWriteStream' => $vendorDir . '/icewind/smb/src/NativeWriteStream.php', | |||||
'Icewind\\SMB\\NotifyHandler' => $vendorDir . '/icewind/smb/src/NotifyHandler.php', | 'Icewind\\SMB\\NotifyHandler' => $vendorDir . '/icewind/smb/src/NotifyHandler.php', | ||||
'Icewind\\SMB\\Parser' => $vendorDir . '/icewind/smb/src/Parser.php', | 'Icewind\\SMB\\Parser' => $vendorDir . '/icewind/smb/src/Parser.php', | ||||
'Icewind\\SMB\\RawConnection' => $vendorDir . '/icewind/smb/src/RawConnection.php', | 'Icewind\\SMB\\RawConnection' => $vendorDir . '/icewind/smb/src/RawConnection.php', |
'Icewind\\SMB\\INotifyHandler' => __DIR__ . '/..' . '/icewind/smb/src/INotifyHandler.php', | 'Icewind\\SMB\\INotifyHandler' => __DIR__ . '/..' . '/icewind/smb/src/INotifyHandler.php', | ||||
'Icewind\\SMB\\IShare' => __DIR__ . '/..' . '/icewind/smb/src/IShare.php', | 'Icewind\\SMB\\IShare' => __DIR__ . '/..' . '/icewind/smb/src/IShare.php', | ||||
'Icewind\\SMB\\NativeFileInfo' => __DIR__ . '/..' . '/icewind/smb/src/NativeFileInfo.php', | 'Icewind\\SMB\\NativeFileInfo' => __DIR__ . '/..' . '/icewind/smb/src/NativeFileInfo.php', | ||||
'Icewind\\SMB\\NativeReadStream' => __DIR__ . '/..' . '/icewind/smb/src/NativeReadStream.php', | |||||
'Icewind\\SMB\\NativeServer' => __DIR__ . '/..' . '/icewind/smb/src/NativeServer.php', | 'Icewind\\SMB\\NativeServer' => __DIR__ . '/..' . '/icewind/smb/src/NativeServer.php', | ||||
'Icewind\\SMB\\NativeShare' => __DIR__ . '/..' . '/icewind/smb/src/NativeShare.php', | 'Icewind\\SMB\\NativeShare' => __DIR__ . '/..' . '/icewind/smb/src/NativeShare.php', | ||||
'Icewind\\SMB\\NativeState' => __DIR__ . '/..' . '/icewind/smb/src/NativeState.php', | 'Icewind\\SMB\\NativeState' => __DIR__ . '/..' . '/icewind/smb/src/NativeState.php', | ||||
'Icewind\\SMB\\NativeStream' => __DIR__ . '/..' . '/icewind/smb/src/NativeStream.php', | 'Icewind\\SMB\\NativeStream' => __DIR__ . '/..' . '/icewind/smb/src/NativeStream.php', | ||||
'Icewind\\SMB\\NativeWriteStream' => __DIR__ . '/..' . '/icewind/smb/src/NativeWriteStream.php', | |||||
'Icewind\\SMB\\NotifyHandler' => __DIR__ . '/..' . '/icewind/smb/src/NotifyHandler.php', | 'Icewind\\SMB\\NotifyHandler' => __DIR__ . '/..' . '/icewind/smb/src/NotifyHandler.php', | ||||
'Icewind\\SMB\\Parser' => __DIR__ . '/..' . '/icewind/smb/src/Parser.php', | 'Icewind\\SMB\\Parser' => __DIR__ . '/..' . '/icewind/smb/src/Parser.php', | ||||
'Icewind\\SMB\\RawConnection' => __DIR__ . '/..' . '/icewind/smb/src/RawConnection.php', | 'Icewind\\SMB\\RawConnection' => __DIR__ . '/..' . '/icewind/smb/src/RawConnection.php', |
[ | [ | ||||
{ | { | ||||
"name": "icewind/smb", | |||||
"version": "v2.0.0", | |||||
"version_normalized": "2.0.0.0", | |||||
"name": "icewind/streams", | |||||
"version": "0.5.2", | |||||
"version_normalized": "0.5.2.0", | |||||
"source": { | "source": { | ||||
"type": "git", | "type": "git", | ||||
"url": "https://github.com/icewind1991/SMB.git", | |||||
"reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a" | |||||
"url": "https://github.com/icewind1991/Streams.git", | |||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e" | |||||
}, | }, | ||||
"dist": { | "dist": { | ||||
"type": "zip", | "type": "zip", | ||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", | |||||
"reference": "95a5ecbaf92617f9800ad7d6070ef31d8ff28c3a", | |||||
"url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e", | |||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e", | |||||
"shasum": "" | "shasum": "" | ||||
}, | }, | ||||
"require": { | "require": { | ||||
"icewind/streams": ">=0.2.0", | |||||
"php": ">=5.4" | |||||
"php": ">=5.3" | |||||
}, | }, | ||||
"require-dev": { | "require-dev": { | ||||
"phpunit/phpunit": "^4.8" | |||||
"phpunit/phpunit": "^4.8", | |||||
"satooshi/php-coveralls": "v1.0.0" | |||||
}, | }, | ||||
"time": "2016-12-13T13:56:55+00:00", | |||||
"time": "2016-12-02T14:21:23+00:00", | |||||
"type": "library", | "type": "library", | ||||
"installation-source": "source", | |||||
"installation-source": "dist", | |||||
"autoload": { | "autoload": { | ||||
"psr-4": { | "psr-4": { | ||||
"Icewind\\SMB\\": "src/", | |||||
"Icewind\\SMB\\Test\\": "tests/" | |||||
"Icewind\\Streams\\Tests\\": "tests/", | |||||
"Icewind\\Streams\\": "src/" | |||||
} | } | ||||
}, | }, | ||||
"notification-url": "https://packagist.org/downloads/", | "notification-url": "https://packagist.org/downloads/", | ||||
"email": "icewind@owncloud.com" | "email": "icewind@owncloud.com" | ||||
} | } | ||||
], | ], | ||||
"description": "php wrapper for smbclient and libsmbclient-php" | |||||
"description": "A set of generic stream wrappers" | |||||
}, | }, | ||||
{ | { | ||||
"name": "icewind/streams", | |||||
"version": "0.5.2", | |||||
"version_normalized": "0.5.2.0", | |||||
"name": "icewind/smb", | |||||
"version": "v2.0.2", | |||||
"version_normalized": "2.0.2.0", | |||||
"source": { | "source": { | ||||
"type": "git", | "type": "git", | ||||
"url": "https://github.com/icewind1991/Streams.git", | |||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e" | |||||
"url": "https://github.com/icewind1991/SMB.git", | |||||
"reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0" | |||||
}, | }, | ||||
"dist": { | "dist": { | ||||
"type": "zip", | "type": "zip", | ||||
"url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e", | |||||
"reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e", | |||||
"url": "https://api.github.com/repos/icewind1991/SMB/zipball/6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", | |||||
"reference": "6691355d9314ac3a8cb9ec9446e4c26e8aab09d0", | |||||
"shasum": "" | "shasum": "" | ||||
}, | }, | ||||
"require": { | "require": { | ||||
"php": ">=5.3" | |||||
"icewind/streams": ">=0.2.0", | |||||
"php": ">=5.4" | |||||
}, | }, | ||||
"require-dev": { | "require-dev": { | ||||
"phpunit/phpunit": "^4.8", | |||||
"satooshi/php-coveralls": "v1.0.0" | |||||
"phpunit/phpunit": "^4.8" | |||||
}, | }, | ||||
"time": "2016-12-02T14:21:23+00:00", | |||||
"time": "2017-08-16T16:08:57+00:00", | |||||
"type": "library", | "type": "library", | ||||
"installation-source": "dist", | |||||
"installation-source": "source", | |||||
"autoload": { | "autoload": { | ||||
"psr-4": { | "psr-4": { | ||||
"Icewind\\Streams\\Tests\\": "tests/", | |||||
"Icewind\\Streams\\": "src/" | |||||
"Icewind\\SMB\\": "src/", | |||||
"Icewind\\SMB\\Test\\": "tests/" | |||||
} | } | ||||
}, | }, | ||||
"notification-url": "https://packagist.org/downloads/", | "notification-url": "https://packagist.org/downloads/", | ||||
"email": "icewind@owncloud.com" | "email": "icewind@owncloud.com" | ||||
} | } | ||||
], | ], | ||||
"description": "A set of generic stream wrappers" | |||||
"description": "php wrapper for smbclient and libsmbclient-php" | |||||
} | } | ||||
] | ] |
<?php | |||||
/** | |||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> | |||||
* This file is licensed under the Licensed under the MIT license: | |||||
* http://opensource.org/licenses/MIT | |||||
*/ | |||||
namespace Icewind\SMB; | |||||
/** | |||||
* Stream optimized for read only usage | |||||
*/ | |||||
class NativeReadStream extends NativeStream { | |||||
const CHUNK_SIZE = 1048576; // 1MB chunks | |||||
/** | |||||
* @var resource | |||||
*/ | |||||
private $readBuffer = null; | |||||
private $bufferSize = 0; | |||||
private $pos = 0; | |||||
public function stream_open($path, $mode, $options, &$opened_path) { | |||||
$this->readBuffer = fopen('php://memory', 'r+'); | |||||
return parent::stream_open($path, $mode, $options, $opened_path); | |||||
} | |||||
/** | |||||
* Wrap a stream from libsmbclient-php into a regular php stream | |||||
* | |||||
* @param \Icewind\SMB\NativeState $state | |||||
* @param resource $smbStream | |||||
* @param string $mode | |||||
* @param string $url | |||||
* @return resource | |||||
*/ | |||||
public static function wrap($state, $smbStream, $mode, $url) { | |||||
stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeReadStream'); | |||||
$context = stream_context_create(array( | |||||
'nativesmb' => array( | |||||
'state' => $state, | |||||
'handle' => $smbStream, | |||||
'url' => $url | |||||
) | |||||
)); | |||||
$fh = fopen('nativesmb://', $mode, false, $context); | |||||
stream_wrapper_unregister('nativesmb'); | |||||
return $fh; | |||||
} | |||||
public function stream_read($count) { | |||||
// php reads 8192 bytes at once | |||||
// however due to network latency etc, it's faster to read in larger chunks | |||||
// and buffer the result | |||||
if (!parent::stream_eof() && $this->bufferSize < $count) { | |||||
$remaining = $this->readBuffer; | |||||
$this->readBuffer = fopen('php://memory', 'r+'); | |||||
$this->bufferSize = 0; | |||||
stream_copy_to_stream($remaining, $this->readBuffer); | |||||
$this->bufferSize += fwrite($this->readBuffer, parent::stream_read(self::CHUNK_SIZE)); | |||||
fseek($this->readBuffer, 0); | |||||
} | |||||
$result = fread($this->readBuffer, $count); | |||||
$this->bufferSize -= $count; | |||||
$read = strlen($result); | |||||
$this->pos += $read; | |||||
return $result; | |||||
} | |||||
public function stream_seek($offset, $whence = SEEK_SET) { | |||||
$result = parent::stream_seek($offset, $whence); | |||||
if ($result) { | |||||
$this->readBuffer = fopen('php://memory', 'r+'); | |||||
$this->bufferSize = 0; | |||||
$this->pos = parent::stream_tell(); | |||||
} | |||||
return $result; | |||||
} | |||||
public function stream_eof() { | |||||
return $this->bufferSize <= 0 && parent::stream_eof(); | |||||
} | |||||
public function stream_tell() { | |||||
return $this->pos; | |||||
} | |||||
public function stream_write($data) { | |||||
return false; | |||||
} | |||||
public function stream_truncate($size) { | |||||
return false; | |||||
} | |||||
} |
$sourceHandle = fopen($source, 'rb'); | $sourceHandle = fopen($source, 'rb'); | ||||
$targetHandle = $this->state->create($this->buildUrl($target)); | $targetHandle = $this->state->create($this->buildUrl($target)); | ||||
while ($data = fread($sourceHandle, 4096)) { | |||||
while ($data = fread($sourceHandle, NativeReadStream::CHUNK_SIZE)) { | |||||
$this->state->write($targetHandle, $data); | $this->state->write($targetHandle, $data); | ||||
} | } | ||||
$this->state->close($targetHandle); | $this->state->close($targetHandle); | ||||
throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading'); | throw new InvalidResourceException('Failed opening remote file "' . $source . '" for reading'); | ||||
} | } | ||||
while ($data = $this->state->read($sourceHandle, 4096)) { | |||||
while ($data = $this->state->read($sourceHandle, NativeReadStream::CHUNK_SIZE)) { | |||||
fwrite($targetHandle, $data); | fwrite($targetHandle, $data); | ||||
} | } | ||||
$this->state->close($sourceHandle); | $this->state->close($sourceHandle); | ||||
public function read($source) { | public function read($source) { | ||||
$url = $this->buildUrl($source); | $url = $this->buildUrl($source); | ||||
$handle = $this->state->open($url, 'r'); | $handle = $this->state->open($url, 'r'); | ||||
return NativeStream::wrap($this->state, $handle, 'r', $url); | |||||
return NativeReadStream::wrap($this->state, $handle, 'r', $url); | |||||
} | } | ||||
/** | /** | ||||
public function write($source) { | public function write($source) { | ||||
$url = $this->buildUrl($source); | $url = $this->buildUrl($source); | ||||
$handle = $this->state->create($url); | $handle = $this->state->create($url); | ||||
return NativeStream::wrap($this->state, $handle, 'w', $url); | |||||
return NativeWriteStream::wrap($this->state, $handle, 'w', $url); | |||||
} | } | ||||
/** | /** |
/** | /** | ||||
* @var \Icewind\SMB\NativeState | * @var \Icewind\SMB\NativeState | ||||
*/ | */ | ||||
private $state; | |||||
protected $state; | |||||
/** | /** | ||||
* @var resource | * @var resource | ||||
*/ | */ | ||||
private $handle; | |||||
protected $handle; | |||||
/** | /** | ||||
* @var bool | * @var bool | ||||
*/ | */ | ||||
private $eof = false; | |||||
protected $eof = false; | |||||
/** | /** | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
private $url; | |||||
protected $url; | |||||
/** | /** | ||||
* Wrap a stream from libsmbclient-php into a regular php stream | * Wrap a stream from libsmbclient-php into a regular php stream | ||||
stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeStream'); | stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeStream'); | ||||
$context = stream_context_create(array( | $context = stream_context_create(array( | ||||
'nativesmb' => array( | 'nativesmb' => array( | ||||
'state' => $state, | |||||
'state' => $state, | |||||
'handle' => $smbStream, | 'handle' => $smbStream, | ||||
'url' => $url | |||||
'url' => $url | |||||
) | ) | ||||
)); | )); | ||||
$fh = fopen('nativesmb://', $mode, false, $context); | $fh = fopen('nativesmb://', $mode, false, $context); |
<?php | |||||
/** | |||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> | |||||
* This file is licensed under the Licensed under the MIT license: | |||||
* http://opensource.org/licenses/MIT | |||||
*/ | |||||
namespace Icewind\SMB; | |||||
/** | |||||
* Stream optimized for write only usage | |||||
*/ | |||||
class NativeWriteStream extends NativeStream { | |||||
const CHUNK_SIZE = 1048576; // 1MB chunks | |||||
/** | |||||
* @var resource | |||||
*/ | |||||
private $writeBuffer = null; | |||||
private $bufferSize = 0; | |||||
private $pos = 0; | |||||
public function stream_open($path, $mode, $options, &$opened_path) { | |||||
$this->writeBuffer = fopen('php://memory', 'r+'); | |||||
return parent::stream_open($path, $mode, $options, $opened_path); | |||||
} | |||||
/** | |||||
* Wrap a stream from libsmbclient-php into a regular php stream | |||||
* | |||||
* @param \Icewind\SMB\NativeState $state | |||||
* @param resource $smbStream | |||||
* @param string $mode | |||||
* @param string $url | |||||
* @return resource | |||||
*/ | |||||
public static function wrap($state, $smbStream, $mode, $url) { | |||||
stream_wrapper_register('nativesmb', '\Icewind\SMB\NativeWriteStream'); | |||||
$context = stream_context_create(array( | |||||
'nativesmb' => array( | |||||
'state' => $state, | |||||
'handle' => $smbStream, | |||||
'url' => $url | |||||
) | |||||
)); | |||||
$fh = fopen('nativesmb://', $mode, false, $context); | |||||
stream_wrapper_unregister('nativesmb'); | |||||
return $fh; | |||||
} | |||||
public function stream_seek($offset, $whence = SEEK_SET) { | |||||
$this->flushWrite(); | |||||
$result = parent::stream_seek($offset, $whence); | |||||
if ($result) { | |||||
$this->pos = parent::stream_tell(); | |||||
} | |||||
return $result; | |||||
} | |||||
private function flushWrite() { | |||||
rewind($this->writeBuffer); | |||||
$this->state->write($this->handle, stream_get_contents($this->writeBuffer)); | |||||
$this->writeBuffer = fopen('php://memory', 'r+'); | |||||
$this->bufferSize = 0; | |||||
} | |||||
public function stream_write($data) { | |||||
$written = fwrite($this->writeBuffer, $data); | |||||
$this->bufferSize += $written; | |||||
$this->pos += $written; | |||||
if ($this->bufferSize >= self::CHUNK_SIZE) { | |||||
$this->flushWrite(); | |||||
} | |||||
return $written; | |||||
} | |||||
public function stream_close() { | |||||
$this->flushWrite(); | |||||
return parent::stream_close(); | |||||
} | |||||
public function stream_tell() { | |||||
return $this->pos; | |||||
} | |||||
public function stream_read($count) { | |||||
return false; | |||||
} | |||||
public function stream_truncate($size) { | |||||
$this->flushWrite(); | |||||
$this->pos = $size; | |||||
return parent::stream_truncate($size); | |||||
} | |||||
} |
public function listen($callback) { | public function listen($callback) { | ||||
if ($this->listening) { | if ($this->listening) { | ||||
$this->connection->read(function ($line) use ($callback) { | $this->connection->read(function ($line) use ($callback) { | ||||
return $callback($this->parseChangeLine($line)); | |||||
$change = $this->parseChangeLine($line); | |||||
if ($change) { | |||||
return $callback($change); | |||||
} | |||||
}); | }); | ||||
} | } | ||||
} | } |