From 4af01023fc4b9ffc4c7174264dbff53966aecc91 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 24 May 2014 01:53:14 +0200 Subject: [PATCH] If the EOF is reached (means no block found or really reached the last block), the whole loaded data needs to be set as currently loaded block. Only setCurrentBlock() needs to be called then. :-) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- inc/classes/main/iterator/io/class_FileIoIterator.php | 10 +++++++--- inc/classes/main/stacker/file/class_BaseFileStack.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/inc/classes/main/iterator/io/class_FileIoIterator.php b/inc/classes/main/iterator/io/class_FileIoIterator.php index ba1019ab..20d351f5 100644 --- a/inc/classes/main/iterator/io/class_FileIoIterator.php +++ b/inc/classes/main/iterator/io/class_FileIoIterator.php @@ -153,13 +153,17 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato 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)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('data()=' . strlen($data)); } // END - if // EOF reached? if ($this->getPointerInstance()->isEndOfFileReached()) { + // Set whole data as current block + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('Calling setCurrentBlock(' . strlen($data) . ') ...'); + $this->setCurrentBlock($data); + // Then abort here silently - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('EOF reached.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('EOF reached.'); return; } // END - if @@ -173,7 +177,7 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato $dataArray = explode(self::getBlockSeparator(), $data); // This array must contain two elements - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('dataArray=' . print_r($dataArray, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('dataArray=' . print_r($dataArray, TRUE)); assert(count($dataArray) == 2); // Left part is the actual block, right one the back-buffer data diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 1ceda761..d16068d3 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -181,7 +181,7 @@ class BaseFileStack extends BaseStacker { $current = $this->getIteratorInstance()->current(); // Simply output it - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] current=%s', __METHOD__, __LINE__, print_r($current, TRUE))); + self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] current(%s)=%s', __METHOD__, __LINE__, strlen($current), print_r($current, TRUE))); } // END - while //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); -- 2.39.5