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 0c08a67..bdfbbf7 100644 (file)
@@ -44,6 +44,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const SEPARATOR_ENTRIES = 0x04;
 
        /**
+        * Separator type->position
+        */
+       const SEPARATOR_TYPE_POSITION = 0x05;
+
+       /**
         * Length of count
         */
        const LENGTH_COUNT = 20;
@@ -59,6 +64,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        const LENGTH_NAME = 10;
 
        /**
+        * Maximum length of entry type
+        */
+       const LENGTH_TYPE = 20;
+
+       /**
         * The real class name
         */
        private $realClass = 'BaseFrameworkSystem';
@@ -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 5fade9b..f8d333b 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 2f0130b..f2eeac3 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 5d055bb..572c1bd 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;