From 2276fafcbfa4cd71fb025ee847205deb1058cc5e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 31 May 2014 13:18:48 +0200 Subject: [PATCH] Continued with file abstraction: - added markCurrentBlockAsEmpty() - added index names for 'gaps' array - fixed typo in method name MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../main/file_directories/class_BaseFile.php | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) 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__)); } -- 2.39.5