From 6e04a11b7ef92c13108b6cfb3e94786a8782eecc Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 24 May 2014 01:32:08 +0200 Subject: [PATCH] Introduced isEndOfFileReached() + added a noisy debug line. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- inc/classes/interfaces/io/class_Pointer.php | 7 +++++++ inc/classes/main/file_directories/class_BaseFileIo.php | 9 +++++++++ inc/classes/main/iterator/io/class_FileIoIterator.php | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/inc/classes/interfaces/io/class_Pointer.php b/inc/classes/interfaces/io/class_Pointer.php index 7b158263..c17d881c 100644 --- a/inc/classes/interfaces/io/class_Pointer.php +++ b/inc/classes/interfaces/io/class_Pointer.php @@ -45,6 +45,13 @@ interface Pointer extends FrameworkInterface { * @return $fileName The current file name */ function getFileName (); + + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + */ + function isEndOfFileReached (); } // [EOF] diff --git a/inc/classes/main/file_directories/class_BaseFileIo.php b/inc/classes/main/file_directories/class_BaseFileIo.php index 845032a0..74e08ccc 100644 --- a/inc/classes/main/file_directories/class_BaseFileIo.php +++ b/inc/classes/main/file_directories/class_BaseFileIo.php @@ -130,6 +130,15 @@ class BaseFileIo extends BaseFrameworkSystem { return ftell($this->getPointer()); } + /** + * Determines whether the EOF has been reached + * + * @return $isEndOfFileReached Whether the EOF has been reached + */ + public final function isEndOfFileReached () { + return feof($this->getPointer()); + } + /** * Seek to given offset (default) or other possibilities as fseek() gives. * diff --git a/inc/classes/main/iterator/io/class_FileIoIterator.php b/inc/classes/main/iterator/io/class_FileIoIterator.php index 7f30fb51..97a3e3d4 100644 --- a/inc/classes/main/iterator/io/class_FileIoIterator.php +++ b/inc/classes/main/iterator/io/class_FileIoIterator.php @@ -150,9 +150,10 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato // Wait until a entry/block separator has been found $data = $this->getBackBuffer(); - while (!$this->getBlockInstance()->isBlockSeparatorFound($data)) { + while (($this->getPointerInstance()->isEndOfFileReached()) && (!$this->getBlockInstance()->isBlockSeparatorFound($data)) { // Then read the block $data .= $this->read($length); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('data()=' . strlen($data)); } // END - if /* -- 2.30.2