mirror of
https://github.com/Rogiel/php-mpq
synced 2025-12-06 00:13:04 +00:00
Implements end-of-file calls on streams
This commit is contained in:
@@ -106,7 +106,7 @@ class BlockStream implements Stream {
|
||||
}
|
||||
|
||||
public function readBytes($bytes) {
|
||||
if($this->position >= $this->block->getSize()) {
|
||||
if($this->eof()) {
|
||||
return false;
|
||||
}
|
||||
if(($this->position + $bytes) > $this->block->getSize()) {
|
||||
@@ -146,6 +146,10 @@ class BlockStream implements Stream {
|
||||
$this->position += $bytes;
|
||||
}
|
||||
|
||||
public function eof() {
|
||||
return $this->position >= $this->block->getSize();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
private function readSector(Sector $sector) {
|
||||
|
||||
@@ -86,4 +86,11 @@ class CompressedStream implements Stream{
|
||||
$this->stream->skip($position);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function eof() {
|
||||
return $this->stream->eof();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -107,4 +107,11 @@ class EncryptedStream implements Stream{
|
||||
$this->bufferPointer = 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function eof() {
|
||||
return $this->stream->eof();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,6 +77,13 @@ class FileStream implements Stream {
|
||||
fseek($this->handle, $position, SEEK_CUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function eof() {
|
||||
return feof($this->handle);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function __clone() {
|
||||
|
||||
@@ -77,4 +77,11 @@ class MemoryStream implements Stream {
|
||||
$this->pointer += $position;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function eof() {
|
||||
return strlen($this->data) >= $this->pointer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,4 +69,8 @@ class BinaryStreamParser {
|
||||
return $this->stream->readBytes($size);
|
||||
}
|
||||
|
||||
public function eof() {
|
||||
return $this->stream->eof();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,4 +64,11 @@ interface Stream {
|
||||
*/
|
||||
public function skip($bytes);
|
||||
|
||||
/**
|
||||
* Checks if the stream has already reached the EOF
|
||||
*
|
||||
* @return boolean if the end of file has been reached
|
||||
*/
|
||||
public function eof();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user