]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/iterator/io/class_FileIoIterator.php
Moved some code to BaseFrameworkSystem, and yes: getBlockSeparator() looks stupid...
[core.git] / inc / classes / main / iterator / io / class_FileIoIterator.php
index 736280a3db49ab13ac4dd14c089d71fd3e1e4393..7f30fb514f1577c829b7d57eeb01f53512bf98d2 100644 (file)
@@ -162,7 +162,7 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
                $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]);
@@ -201,8 +201,17 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
                // 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;