// 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
+
+ // EOF reached?
+ if ($this->getPointerInstance()->isEndOfFileReached()) {
+ // Then abort here silently
+ return;
} // END - if
/*
$this->initBackBuffer();
// Separate data
- $dataArray = explode($this->getBlockInstance()->getBlockSeparator(), $data);
+ $dataArray = explode(self::getBlockSeparator(), $data);
// Left part is the actual block, right one the back-buffer data
$this->setCurrentBlock($dataArray[0]);
// If some bytes could be read, all is fine
$isValid = ((is_string($data)) && (strlen($data) > 0));
- // Seek back to old position
- $this->seek($seekPosition);
+ // Get header size
+ $headerSize = $this->getBlockInstance()->getHeaderSize();
+
+ // Is the seek position at or beyond the header?
+ if ($seekPosition >= $headerSize) {
+ // Seek back to old position
+ $this->seek($seekPosition);
+ } else {
+ // Seek directly behind the header
+ $this->seek($headerSize);
+ }
// Return result
return $isValid;