]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/class_BaseFrameworkSystem.php
Switched from unabstracted file pointer class to a better abstract approach (unfinished).
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 06f3a4d6d6debc47f5201b4ad1fa3c9df52f4207..8b6707dd2c7a282d62b8efa8b360fa5953811551 100644 (file)
@@ -3054,6 +3054,30 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Simple flush file header which will create it.
                $this->flushFileHeader();
 
+               // Rewind seek position (to beginning of file) and update/flush file header
+               $this->rewineUpdateSeekPosition();
+
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!!', __METHOD__, __LINE__));
+       }
+
+       /**
+        * Seeks to beginning of file, updates seek position in this object and
+        * flushes the header.
+        *
+        * @return      void
+        */
+       protected function rewineUpdateSeekPosition () {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
+
+               // Seek to beginning of file
+               $this->getIteratorInstance()->rewind();
+
+               // And update seek position ...
+               $this->updateSeekPosition();
+
+               // ... to write it back into the file
+               $this->flushFileHeader();
+
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!!', __METHOD__, __LINE__));
        }
 
@@ -3063,8 +3087,12 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @return      void
         */
        protected function seekToOldPosition () {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
+
                // Seek to currently ("old") saved position
                $this->getIteratorInstance()->seek($this->getSeekPosition());
+
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!!', __METHOD__, __LINE__));
        }
 
        /**
@@ -3088,10 +3116,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                if ($flushHeader === TRUE) {
                        // Flush header
                        $this->flushFileHeader();
+
+                       // Seek to old position
+                       $this->seekToOldPosition();
                } // END - if
 
-               // Seek to old position
-               $this->seekToOldPosition();
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
 
@@ -3130,6 +3159,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Now simply write a NUL there. This will pre-allocate the file.
                $this->writeData($seekPosition, chr(0));
 
+               // Rewind seek position (to beginning of file) and update/flush file header
+               $this->rewineUpdateSeekPosition();
+
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
 }