X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fiterator%2Fio%2Fclass_FileIoIterator.php;h=20d351f5e694d09b43376e8d1badc8b6f7368dfa;hp=888652f6300aa3752fd6a5670b7af898b04c3d18;hb=4af01023fc4b9ffc4c7174264dbff53966aecc91;hpb=02fddec6dfaf6a1be1f9612e95967656556b4189 diff --git a/inc/classes/main/iterator/io/class_FileIoIterator.php b/inc/classes/main/iterator/io/class_FileIoIterator.php index 888652f6..20d351f5 100644 --- a/inc/classes/main/iterator/io/class_FileIoIterator.php +++ b/inc/classes/main/iterator/io/class_FileIoIterator.php @@ -150,10 +150,21 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato // Wait until a entry/block separator has been found $data = $this->getBackBuffer(); - while (($this->getPointerInstance()->isEndOfFileReached()) && (!$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)); + //* 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.'); + return; } // END - if /* @@ -165,6 +176,10 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato // Separate data $dataArray = explode(self::getBlockSeparator(), $data); + // This array must contain two elements + //* 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 $this->setCurrentBlock($dataArray[0]); $this->setBackBuffer($dataArray[1]);