Commit 386e3978 authored by Jeremy Mikola's avatar Jeremy Mikola

Resolve StreamWrapper todo items for read/write differences

WritableStreams cannot be read and are never EOF. ReadableStreams cannot be written.
parent 7a6bb13d
......@@ -57,6 +57,10 @@ class StreamWrapper
*/
public function stream_eof()
{
if ( ! $this->stream instanceof ReadableStream) {
return false;
}
return $this->stream->isEOF();
}
......@@ -93,11 +97,14 @@ class StreamWrapper
*
* @see http://php.net/manual/en/streamwrapper.stream-read.php
* @param integer $count Number of bytes to read
* @return string
* @return string
*/
public function stream_read($count)
{
// TODO: Ensure that $this->stream is a ReadableStream
if ( ! $this->stream instanceof ReadableStream) {
return '';
}
return $this->stream->downloadNumBytes($count);
}
......@@ -122,13 +129,15 @@ class StreamWrapper
*
* @see http://php.net/manual/en/streamwrapper.stream-write.php
* @param string $data Data to write
* @return integer The number of bytes successfully stored
* @return integer The number of bytes written
*/
public function stream_write($data)
{
// TODO: Ensure that $this->stream is a WritableStream
$this->stream->insertChunks($data);
if ( ! $this->stream instanceof WritableStream) {
return 0;
}
$this->stream->insertChunks($data);
return strlen($data);
}
......
......@@ -184,11 +184,6 @@ class WritableStream
return $readBytes;
}
public function isEOF()
{
return $this->isClosed;
}
private function abort()
{
$this->collectionWrapper->deleteChunksByFilesId($this->file['_id']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment