]> git.mxchange.org Git - core.git/commitdiff
Continued with file abstraction:
authorRoland Haeder <roland@mxchange.org>
Sat, 31 May 2014 11:18:48 +0000 (13:18 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 31 May 2014 11:18:48 +0000 (13:18 +0200)
- added markCurrentBlockAsEmpty()
- added index names for 'gaps' array
- fixed typo in method name

Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/file_directories/class_BaseFile.php

index 1d3dac19e1e0016769992519d5088cc532867e72..d228d796f60f5169bfea730a8cb741f191a58295 100644 (file)
@@ -67,6 +67,18 @@ class BaseFile extends BaseFrameworkSystem {
         */
        const LENGTH_TYPE = 20;
 
+       //***** Array elements for 'gaps' array *****
+
+       /**
+        * Start of gap
+        */
+       const GAPS_INDEX_START = 'start';
+
+       /**
+        * End of gap
+        */
+       const GAPS_INDEX_END = 'end';
+
        /**
         * Length of output from hash()
         */
@@ -280,7 +292,7 @@ y    * @return      void
         *
         * @return      void
         */
-       protected function rewineUpdateSeekPosition () {
+       protected function rewindUpdateSeekPosition () {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
 
                // flushFileHeader must be callable
@@ -456,6 +468,23 @@ y   * @return      void
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
 
+       /**
+        * Marks the currently loaded block as empty (with length of the block)
+        *
+        * @param       $length         Length of the block
+        * @return      void
+        */
+       protected function markCurrentBlockAsEmpty ($length) {
+               // Get current seek position
+               $currentPosition = $this->key();
+
+               // Now add it as gap entry
+               array_push($this->gaps, array(
+                       self::GAPS_INDEX_START  => ($currentPosition - $length),
+                       self::GAPS_INDEX_END    => $currentPosition,
+               ));
+       }
+
        /**
         * Checks whether the file header is initialized
         *
@@ -532,7 +561,7 @@ y    * @return      void
                $this->flushFileHeader();
 
                // Rewind seek position (to beginning of file) and update/flush file header
-               $this->rewineUpdateSeekPosition();
+               $this->rewindUpdateSeekPosition();
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!!', __METHOD__, __LINE__));
        }
@@ -570,7 +599,7 @@ y    * @return      void
                $this->writeData($seekPosition, chr(0));
 
                // Rewind seek position (to beginning of file) and update/flush file header
-               $this->rewineUpdateSeekPosition();
+               $this->rewindUpdateSeekPosition();
 
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }