From: Roland Haeder <roland@mxchange.org>
Date: Sat, 31 May 2014 11:18:48 +0000 (+0200)
Subject: Continued with file abstraction:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2276fafcbfa4cd71fb025ee847205deb1058cc5e;p=core.git

Continued with file abstraction:
- added markCurrentBlockAsEmpty()
- added index names for 'gaps' array
- fixed typo in method name

Signed-off-by: Roland Häder <roland@mxchange.org>
---

diff --git a/inc/classes/main/file_directories/class_BaseFile.php b/inc/classes/main/file_directories/class_BaseFile.php
index 1d3dac19..d228d796 100644
--- a/inc/classes/main/file_directories/class_BaseFile.php
+++ b/inc/classes/main/file_directories/class_BaseFile.php
@@ -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__));
 	}