Continued:
authorRoland Haeder <roland@mxchange.org>
Sat, 24 May 2014 14:34:04 +0000 (16:34 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 24 May 2014 14:34:04 +0000 (16:34 +0200)
- removed getBlockSeparator()
- added calculation of minimum length of an index entry

Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/file_directories/class_BaseFile.php
inc/classes/main/index/class_BaseIndex.php
inc/classes/main/stacker/file/class_BaseFileStack.php

index 0c08a67a364a0cee1d477d3facee68b7abcbeaa6..bdfbbf7b183c8761e5765e1a611642160a52e04f 100644 (file)
@@ -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]
index 5fade9baeeaaded5a0f87f0af175e2fed130e20d..f8d333b67be084854534212e31be98006f588150 100644 (file)
@@ -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));
index 2f0130b643d0e0e633a37d0a711f9dd4c8ce7a46..f2eeac33b33bdcbc922c506e22abe1368fce7d0c 100644 (file)
@@ -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;
index 5d055bb78f1a8ebec694d8d7b6a956d0cb064373..572c1bd9ba7e7286e461b12479cdd6bcba262b41 100644 (file)
@@ -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;