+ // Is there nothing to read?
+ if (!$this->valid()) {
+ // Nothing to read
+ return;
+ } // END - if
+
+ // First calculate minimum block length
+ $length = $this->getBlockInstance()->caluclateMinimumBlockLength();
+
+ // Short be more than zero!
+ assert($length > 0);
+
+ // Wait until a entry/block separator has been found
+ $data = $this->getBackBuffer();
+ 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()) {
+ // 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
+
+ /*
+ * Init back-buffer which is the data that has been found beyond the
+ * separator.
+ */
+ $this->initBackBuffer();
+
+ // 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]);