From: Roland Haeder Date: Sat, 24 May 2014 14:34:04 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=43a245de11669d9da341a2db7a35b956871adeb9;p=core.git Continued: - removed getBlockSeparator() - added calculation of minimum length of an index entry Signed-off-by: Roland Häder --- diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 0c08a67a..bdfbbf7b 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -43,6 +43,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ const SEPARATOR_ENTRIES = 0x04; + /** + * Separator type->position + */ + const SEPARATOR_TYPE_POSITION = 0x05; + /** * Length of count */ @@ -58,6 +63,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ const LENGTH_NAME = 10; + /** + * Maximum length of entry type + */ + const LENGTH_TYPE = 20; + /** * The real class name */ @@ -3068,20 +3078,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ public static function isBlockSeparatorFound ($str) { // Determine it - $isFound = (strpos($str, self::getBlockSeparator()) !== FALSE); + $isFound = (strpos($str, chr(self::SEPARATOR_ENTRIES)) !== FALSE); // Return result return $isFound; } - - /** - * Getter for block separator character(s) - * - * @return $blockSeparator A separator for blocks - */ - protected static final function getBlockSeparator () { - return chr(self::SEPARATOR_ENTRIES); - } } // [EOF] diff --git a/inc/classes/main/file_directories/class_BaseFile.php b/inc/classes/main/file_directories/class_BaseFile.php index 5fade9ba..f8d333b6 100644 --- a/inc/classes/main/file_directories/class_BaseFile.php +++ b/inc/classes/main/file_directories/class_BaseFile.php @@ -504,7 +504,7 @@ y * @return void $this->initBackBuffer(); // Separate data - $dataArray = explode(self::getBlockSeparator(), $data); + $dataArray = explode(chr(self::SEPARATOR_ENTRIES), $data); // This array must contain two elements //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('dataArray=' . print_r($dataArray, TRUE)); diff --git a/inc/classes/main/index/class_BaseIndex.php b/inc/classes/main/index/class_BaseIndex.php index 2f0130b6..f2eeac33 100644 --- a/inc/classes/main/index/class_BaseIndex.php +++ b/inc/classes/main/index/class_BaseIndex.php @@ -40,9 +40,9 @@ class BaseIndex extends BaseFrameworkSystem { // Calculate header size $this->setHeaderSize( strlen(self::INDEX_MAGIC) + - strlen(self::SEPARATOR_HEADER_DATA) + + strlen(chr(self::SEPARATOR_HEADER_DATA)) + self::LENGTH_COUNT + - strlen(self::SEPARATOR_HEADER_ENTRIES) + strlen(chr(self::SEPARATOR_HEADER_ENTRIES)) ); // Init counters and gaps array @@ -184,8 +184,7 @@ class BaseIndex extends BaseFrameworkSystem { */ public function calculateMinimumBlockLength () { // Calulcate it - // @TODO Not finished yet - $length = 0; + $length = self::LENGTH_TYPE + strlen(chr(self::SEPARATOR_TYPE_POSITION)) + self::LENGTH_POSITION + strlen(chr(self::SEPARATOR_ENTRIES)); // Return it return $length; diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 5d055bb7..572c1bd9 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -40,11 +40,11 @@ class BaseFileStack extends BaseStacker { // Calculate header size $this->setHeaderSize( strlen(self::STACK_MAGIC) + - strlen(self::SEPARATOR_HEADER_DATA) + + strlen(chr(self::SEPARATOR_HEADER_DATA)) + self::LENGTH_COUNT + - strlen(self::SEPARATOR_HEADER_DATA) + + strlen(chr(self::SEPARATOR_HEADER_DATA)) + self::LENGTH_POSITION + - strlen(self::SEPARATOR_HEADER_ENTRIES) + strlen(chr(self::SEPARATOR_HEADER_ENTRIES)) ); // Init counters and gaps array @@ -410,7 +410,7 @@ class BaseFileStack extends BaseStacker { */ public function calculateMinimumBlockLength () { // Calulcate it - $length = self::getHashLength() + strlen(chr(self::SEPARATOR_HASH_NAME)) + self::LENGTH_NAME + 1 + strlen(self::getBlockSeparator()); + $length = self::getHashLength() + strlen(chr(self::SEPARATOR_HASH_NAME)) + self::LENGTH_NAME + 1 + strlen(chr(self::SEPARATOR_ENTRIES)); // Return it return $length;