]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/binary/stack/class_StackFile.php
Continued:
[core.git] / framework / main / classes / file_directories / binary / stack / class_StackFile.php
index 42a2412f007c4e28bb154f726f33fad5f2496ae9..590a7fca5f90683467552cbf23ef626b0dcdcea7 100644 (file)
@@ -158,6 +158,41 @@ class StackFile extends BaseBinaryFile implements FileStacker {
                return $isValid;
        }
 
+       /**
+        * Reads the file header
+        *
+        * @return      void
+        * @throws      LogicException  If both instances are not set
+        */
+       public function readFileHeader () {
+               // Call stacke instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: Calling this->stackInstance->readStackHeader() - CALLED!');
+               $this->getStackInstance()->readStackHeader();
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: EXIT!');
+       }
+
+       /**
+        * Reads next "block" of bytes into $currentBlock field. THis method loads
+        * the whole file into memory when the file is just freshly initialized
+        * (only zeros in it).
+        *
+        * @return      void
+        */
+       protected function readNextBlock () {
+               // First calculate minimum block length
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: this->seekPosition=%d - CALLED!', $this->getSeekPosition()));
+               $length = $this->getStackInstance()->calculateMinimumBlockLength();
+
+               // Call protected method
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling parent::readNextBlockByLength(%d) ...', $length));
+               parent::readNextBlockByLength($length);
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('STACK-FILE: EXIT!');
+       }
+
        /**
         * Writes given value to the file and returns a hash and gap position for it
         *
@@ -178,15 +213,19 @@ class StackFile extends BaseBinaryFile implements FileStacker {
                }
 
                // Encode/convert the value into a "binary format"
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling StringUtils::encodeData(value[]=%s) ...', gettype($value)));
                $encoded = StringUtils::encodeData($value);
 
                // Get a strong hash for the "encoded" data
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling CryptoUtils::hash(%s) ...', $encoded));
                $hash = CryptoUtils::hash($encoded);
 
                // Then write it to the next free gap
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: Calling this->stackInstance->writeDataToFreeGap(%s,%s,%s) ...', $stackName, $hash, $encoded));
                $data = $this->getStackInstance()->writeDataToFreeGap($stackName, $hash, $encoded);
 
                // Return info
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('STACK-FILE: data[]=%s - EXIT!', gettype($data)));
                return $data;
        }