Introduced isEndOfFileReached() + added a noisy debug line.
authorRoland Haeder <roland@mxchange.org>
Fri, 23 May 2014 23:32:08 +0000 (01:32 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 23 May 2014 23:32:08 +0000 (01:32 +0200)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/interfaces/io/class_Pointer.php
inc/classes/main/file_directories/class_BaseFileIo.php
inc/classes/main/iterator/io/class_FileIoIterator.php

index 7b15826..c17d881 100644 (file)
@@ -45,6 +45,13 @@ interface Pointer extends FrameworkInterface {
         * @return      $fileName       The current file name
         */
        function getFileName ();
+
+       /**
+        * Determines whether the EOF has been reached
+        *
+        * @return      $isEndOfFileReached             Whether the EOF has been reached
+        */
+       function isEndOfFileReached ();
 }
 
 // [EOF]
index 845032a..74e08cc 100644 (file)
@@ -130,6 +130,15 @@ class BaseFileIo extends BaseFrameworkSystem {
                return ftell($this->getPointer());
        }
 
+       /**
+        * Determines whether the EOF has been reached
+        *
+        * @return      $isEndOfFileReached             Whether the EOF has been reached
+        */
+       public final function isEndOfFileReached () {
+               return feof($this->getPointer());
+       }
+
        /**
         * Seek to given offset (default) or other possibilities as fseek() gives.
         *
index 7f30fb5..97a3e3d 100644 (file)
@@ -150,9 +150,10 @@ class FileIoIterator extends BaseIterator implements SeekableWritableFileIterato
 
                // 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
 
                /*