Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 8 Dec 2020 23:20:01 +0000 (00:20 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 8 Dec 2020 23:20:01 +0000 (00:20 +0100)
- commented out a lot debug messages
- still closeFile() and __destruct() interfere with PHPUnit's output
- Fixed bugs in pre-allocating binary files and needed to add 2 to header size for first free gap
- also introduced some private methods to ease adding gaps (start/end seek positions)

Signed-off-by: Roland Häder <roland@mxchange.org>
14 files changed:
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/file_directories/binary/class_BaseBinaryFile.php
framework/main/classes/file_directories/class_BaseAbstractFile.php
framework/main/classes/file_directories/class_BaseFileIo.php
framework/main/classes/file_directories/input/raw/class_FrameworkRawFileInputPointer.php
framework/main/classes/file_directories/input/text/class_FrameworkTextFileInputPointer.php
framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php
framework/main/classes/file_directories/output/raw/class_FrameworkRawFileOutputPointer.php
framework/main/classes/file_directories/output/text/class_FrameworkTextFileOutputPointer.php
framework/main/classes/index/class_BaseIndex.php
framework/main/classes/iterator/file/class_FileIterator.php
framework/main/classes/stacker/file/class_BaseFileStack.php
framework/main/interfaces/block/class_Block.php
framework/main/interfaces/iterator/file/class_SeekableWritableFileIterator.php

index 49d58164104e88d0af315cba048df16d05a3844e..e9ce996fe89890f8dea7bb437113e5d2ab07fc8f 100644 (file)
@@ -629,7 +629,7 @@ Loaded includes:
                                $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className);
                        } catch (NullPointerException $e) {
                                // Didn't work, no instance there
-                               exit(sprintf('Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, $e->__toString(), $e->getMessage(), $className, $lineNumber));
+                               exit(sprintf('[%s:%d]: Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, __METHOD__, __LINE__, $e->__toString(), $e->getMessage(), $className, $lineNumber));
                        }
 
                        // Empty string should be ignored and used for testing the middleware
index 187ac493e0e64213d735ec799dab392f508b6deb..4ed66c22dbc482b1c1deb5ae43c377e5993432e5 100644 (file)
@@ -174,49 +174,44 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
        }
 
        /**
-        * Checks whether the abstracted file only contains gaps by counting all
-        * gaps' bytes together and compare it to total length.
+        * Setter for backBuffer field
         *
-        * @return      $isGapsOnly             Whether the abstracted file only contains gaps
+        * @param       $backBuffer             Characters to "store" in back-buffer
+        * @return      void
         */
-       private function isFileOnlyGaps () {
-               // Count every gap
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
-               $gapsSize = 0;
-               foreach ($this->gaps as $gap) {
-                       // Calculate size of found gap: end-start including both
-                       $gapsSize += ($gap[self::GAPS_INDEX_END] - $gap[self::GAPS_INDEX_START]);
-               }
-
-               // Total gap size + header size must be same as file size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: gapsSize=%s,this->headerSize=%s', $gapsSize, $this->getHeaderSize()));
-               $isGapsOnly = (($this->getHeaderSize() + $gapsSize) == $this->getFileSize());
+       private function setBackBuffer (string $backBuffer) {
+               // ... and set it
+               $this->backBuffer = $backBuffer;
+       }
 
-               // Return status
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isGapsOnly=%d - EXIT!', intval($isGapsOnly)));
-               return $isGapsOnly;
+       /**
+        * Getter for backBuffer field
+        *
+        * @return      $backBuffer             Characters "stored" in back-buffer
+        */
+       private function getBackBuffer () {
+               return $this->backBuffer;
        }
 
        /**
-        * Initializes counter for valid entries, arrays for damaged entries and
-        * an array for gap seek positions. If you call this method on your own,
-        * please re-analyze the file structure. So you are better to call
-        * analyzeFile() instead of this method.
+        * Setter for currentBlock field
         *
+        * @param       $currentBlock   Characters to set a currently loaded block
         * @return      void
         */
-       public function initCountersGapsArray () {
-               // Init counter and seek position to header size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
-               $this->setCounter(0);
-               $this->setSeekPosition($this->getHeaderSize());
-
-               // Init arrays
-               $this->gaps = [];
-               $this->damagedEntries = [];
+       private function setCurrentBlock (string $currentBlock) {
+               // ... and set it
+               $this->currentBlock = $currentBlock;
+       }
 
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+       /**
+        * Gets currently read data
+        *
+        * @return      $current        Currently read data
+        */
+       public function getCurrentBlock () {
+               // Return it
+               return $this->currentBlock;
        }
 
        /**
@@ -225,7 +220,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         * @return      $totalEntries   Size of file header
         */
        public final function getHeaderSize () {
-               // Get it
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Getting this->headerSize=%d - CALLED!', $this->headerSize));
                return $this->headerSize;
        }
 
@@ -236,7 +231,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         * @return      void
         */
        public final function setHeaderSize (int $headerSize) {
-               // Set it
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting headerSize=%d - CALLED!', $headerSize));
                $this->headerSize = $headerSize;
        }
 
@@ -267,7 +262,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         * @return      $seekPosition   Current seek position (stored here in object)
         */
        public final function getSeekPosition () {
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Getting this->seekPosition=%d - CALLED!', $this->seekPosition));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Getting this->seekPosition=%d - CALLED!', $this->seekPosition));
                return $this->seekPosition;
        }
 
@@ -278,23 +273,86 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         * @return      void
         */
        protected final function setSeekPosition (int $seekPosition) {
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting seekPosition=%d - CALLED!', $seekPosition));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting seekPosition=%d - CALLED!', $seekPosition));
                $this->seekPosition = $seekPosition;
        }
 
        /**
-        * Updates seekPosition attribute from file to avoid to much access on file.
+        * Marks whole file as gaps-only (freshly created file
         *
+        * @param       $type   Type of file
+        * @param       $minimumBlockLength             Minimum block length
         * @return      void
         */
-       public function updateSeekPosition () {
-               // Get key (= seek position)
+       private function markFileGapsOnly (string $type, int $minimumBlockLength) {
+               // Very simple to do ...
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
+               for ($idx = 0; $idx < FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_count'); $idx++) {
+                       // Mark start and end position as gap
+                       $this->addGap($idx * $minimumBlockLength, $idx * $minimumBlockLength + $minimumBlockLength);
+               }
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+       }
+
+       /**
+        * Checks whether the abstracted file only contains gaps by counting all
+        * gaps' bytes together and compare it to total length.
+        *
+        * @return      $isGapsOnly             Whether the abstracted file only contains gaps
+        */
+       private function isFileGapsOnly () {
+               // Count every gap
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
-               $seekPosition = $this->key();
+               $gapsSize = 0;
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: this->gaps()=%d', count($this->gaps)));
+               foreach ($this->gaps as $gap) {
+                       // Calculate size of found gap: end-start including both
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: gap[%s]=%d,ga[%s]=%d', self::GAPS_INDEX_START, $gap[self::GAPS_INDEX_START], self::GAPS_INDEX_END, $gap[self::GAPS_INDEX_END]));
+                       $gapsSize += ($gap[self::GAPS_INDEX_END] - $gap[self::GAPS_INDEX_START]);
 
-               // And set it here
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
-               $this->setSeekPosition($seekPosition);
+                       // Debug message
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: gapsSize=%d', $gapsSize));
+               }
+
+               // Total gap size + header size must be same as file size
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: gapsSize=%d,this->fileSize=%d', $gapsSize, $this->getFileSize()));
+               $isGapsOnly = ($gapsSize + 1 == $this->getFileSize());
+
+               // Return status
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isGapsOnly=%d - EXIT!', intval($isGapsOnly)));
+               return $isGapsOnly;
+       }
+
+       /**
+        * Adds a gap for given start and end position
+        *
+        * @param       $startPosition  Start seek position
+        * @param       $endPosition    End seek position
+        * @return      void
+        */
+       private function addGap(int $startPosition, int $endPosition) {
+               // Push to gaps array
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: startPosition=%d,endPosition=%d - CALLED!', $startPosition, $endPosition));
+               array_push($this->gaps, [
+                       self::GAPS_INDEX_START  => $startPosition,
+                       self::GAPS_INDEX_END    => $endPosition,
+               ]);
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+       }
+
+       /**
+        * Initializes the back-buffer by setting it to an empty string.
+        *
+        * @return      void
+        */
+       private function initBackBuffer () {
+               // Simply call the setter
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               $this->setBackBuffer('');
 
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
@@ -342,100 +400,111 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
        }
 
        /**
-        * Checks whether the block separator has been found
+        * Initializes this file class
         *
-        * @param       $str            String to look in
-        * @return      $isFound        Whether the block separator has been found
-        * @throws      InvalidArgumentException        If a parameter is not valid
+        * @param       $fileInfoInstance       An instance of a SplFileInfo class
+        * @return      void
         */
-       public static function isBlockSeparatorFound (string $str) {
-               // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: str=%s - CALLED!', $str));
-               if (empty($str)) {
-                       // Throw IAE
-                       throw new InvalidArgumentException('Parameter "str" is empty');
-               }
+       protected function initFile (SplFileInfo $fileInfoInstance) {
+               // Get a file i/o pointer instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: fileInfoInstance[%s]=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance));
+               $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileInfoInstance));
 
-               // Determine it
-               $isFound = (strpos($str, chr(self::SEPARATOR_ENTRIES)) !== false);
+               // ... and set it here
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting pointerInstance=%s ...', $pointerInstance->__toString()));
+               $this->setPointerInstance($pointerInstance);
 
-               // Return result
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isFound=%d - EXIT!', intval($isFound)));
-               return $isFound;
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
        }
 
        /**
-        * Initializes the back-buffer by setting it to an empty string.
+        * Marks the currently loaded block as empty (with length of the block)
         *
+        * @param       $length         Length of the block
         * @return      void
+        * @throws      InvalidArgumentException        If a parameter is invalid
         */
-       private function initBackBuffer () {
-               // Simply call the setter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
-               $this->setBackBuffer('');
+       protected function markCurrentBlockAsEmpty (int $length) {
+               // Validate parameter
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
+               if ($length < 1) {
+                       // Length cannot below one
+                       throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
+               }
+
+               // Get current seek position
+               $currentPosition = $this->key();
+
+               // Now add it as gap entry
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: currentPosition=%d', $currentPosition));
+               $this->addGap(($currentPosition - $length), $currentPosition);
 
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
        }
 
        /**
-        * Setter for backBuffer field
+        * Initializes counter for valid entries, arrays for damaged entries and
+        * an array for gap seek positions. If you call this method on your own,
+        * please re-analyze the file structure. So you are better to call
+        * analyzeFileStructure() instead of this method.
         *
-        * @param       $backBuffer             Characters to "store" in back-buffer
         * @return      void
         */
-       private function setBackBuffer (string $backBuffer) {
-               // ... and set it
-               $this->backBuffer = $backBuffer;
-       }
+       public function initCountersGapsArray () {
+               // Init counter and seek position to header size
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               $this->setCounter(0);
+               $this->setSeekPosition($this->getHeaderSize());
 
-       /**
-        * Getter for backBuffer field
-        *
-        * @return      $backBuffer             Characters "stored" in back-buffer
-        */
-       private function getBackBuffer () {
-               return $this->backBuffer;
+               // Init arrays
+               $this->gaps = [];
+               $this->damagedEntries = [];
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
        }
 
        /**
-        * Setter for currentBlock field
+        * Updates seekPosition attribute from file to avoid to much access on file.
         *
-        * @param       $currentBlock   Characters to set a currently loaded block
         * @return      void
         */
-       private function setCurrentBlock (string $currentBlock) {
-               // ... and set it
-               $this->currentBlock = $currentBlock;
-       }
+       public function updateSeekPosition () {
+               // Get key (= seek position)
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               $seekPosition = $this->key();
 
-       /**
-        * Gets currently read data
-        *
-        * @return      $current        Currently read data
-        */
-       public function getCurrentBlock () {
-               // Return it
-               return $this->currentBlock;
+               // And set it here
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
+               $this->setSeekPosition($seekPosition);
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
        }
 
        /**
-        * Initializes this file class
+        * Checks whether the block separator has been found
         *
-        * @param       $fileInfoInstance       An instance of a SplFileInfo class
-        * @return      void
+        * @param       $str            String to look in
+        * @return      $isFound        Whether the block separator has been found
+        * @throws      InvalidArgumentException        If a parameter is not valid
         */
-       protected function initFile (SplFileInfo $fileInfoInstance) {
-               // Get a file i/o pointer instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: fileInfoInstance[%s]=%s - CALLED!', get_class($fileInfoInstance), $fileInfoInstance));
-               $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileInfoInstance));
+       public static function isBlockSeparatorFound (string $str) {
+               // Validate parameter
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: str=%s - CALLED!', $str));
+               if (empty($str)) {
+                       // Throw IAE
+                       throw new InvalidArgumentException('Parameter "str" is empty');
+               }
 
-               // ... and set it here
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Setting pointerInstance=%s ...', $pointerInstance->__toString()));
-               $this->setPointerInstance($pointerInstance);
+               // Determine it
+               $isFound = (strpos($str, chr(self::SEPARATOR_ENTRIES)) !== false);
 
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+               // Return result
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isFound=%d - EXIT!', intval($isFound)));
+               return $isFound;
        }
 
        /**
@@ -514,34 +583,6 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                return $status;
        }
 
-       /**
-        * Marks the currently loaded block as empty (with length of the block)
-        *
-        * @param       $length         Length of the block
-        * @return      void
-        * @throws      InvalidArgumentException        If a parameter is invalid
-        */
-       protected function markCurrentBlockAsEmpty (int $length) {
-               // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d - CALLED!', $length));
-               if ($length < 1) {
-                       // Length cannot below one
-                       throw new InvalidArgumentException(sprintf('length=%d is not valid', $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,
-               ));
-
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
-       }
-
        /**
         * Checks whether the file header is initialized
         *
@@ -648,18 +689,31 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                // Message to user
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Pre-allocating file ...');
 
-               // Calculate minimum length for one entry
+               // Calculate minimum length for one entry and get file size
                $minimumBlockLength = $this->getBlockInstance()->calculateMinimumBlockLength();
+               $fileSize = $this->getFileSize();
 
                // Calulcate seek position
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: minimumBlockLength=%s', $minimumBlockLength));
-               $seekPosition = $minimumBlockLength * FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_count');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: minimumBlockLength=%d,fileSize=%d', $minimumBlockLength, $fileSize));
+               $seekPosition = $minimumBlockLength * FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_count') + $fileSize ;
 
                // Now simply write a NUL there. This will pre-allocate the file.
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->writeAtPosition(%d,NUL) ...', $seekPosition));
                $this->writeAtPosition($seekPosition, chr(0));
 
+               // Is the seek position zero?
+               if ($fileSize == 0) {
+                       // Mark file as gaps-only
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Calling this->markGapsOnly(%s) ...', $type));
+                       $this->markFileGapsOnly($type, $minimumBlockLength);
+               } else {
+                       // Analyze file structure
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->analyzeFileStructure() ...');
+                       $this->analyzeFileStructure();
+               }
+
                // Rewind seek position
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: Calling this->rewind() ...');
                $this->rewind();
 
                // Trace message
@@ -673,7 +727,12 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         */
        public function determineSeekPosition () {
                // Call pointer instance
-               return $this->getPointerInstance()->determineSeekPosition();
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               $seekPosition = $this->getPointerInstance()->determineSeekPosition();
+
+               // Return position
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d - EXIT!', $seekPosition));
+               return $seekPosition;
        }
 
        /**
@@ -682,10 +741,22 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         * @param       $offset         Offset to seek to (or used as "base" for other seeks)
         * @param       $whence         Added to offset (default: only use offset to seek to)
         * @return      $status         Status of file seek: 0 = success, -1 = failed
+        * @throws      InvalidArgumentException         If a parameter is not valid
         */
        public function seek (int $offset, int $whence = SEEK_SET) {
+               // Validate parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: offset=%d,whence=%d - CALLED!', $offset, $whence));
+               if ($offset < 0) {
+                       // No offset is smaller than zero
+                       throw new InvalidArgumentException(sprintf('offset=%d is not valid', $offset));
+               }
+
                // Call pointer instance
-               return $this->getPointerInstance()->seek($offset, $whence);
+               $status = $this->getPointerInstance()->seek($offset, $whence);
+
+               // Return status
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: status[%s]=%d - EXIT!', gettype($status), $status));
+               return $status;
        }
 
        /**
@@ -693,20 +764,36 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         *
         * @param       $bytes  Amount of bytes to read
         * @return      $data   Data read from file
+        * @throws      InvalidArgumentException         If a parameter is not valid
         */
        public function read (int $bytes = 0) {
+               // Validate parameter
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: bytes=%d - CALLED!', $bytes));
+               if ($bytes < 0) {
+                       // Throw IAE
+                       throw new InvalidArgumentException(sprintf('bytes=%d is not valid', $bytes));
+               }
+
                // Call pointer instance
-               return $this->getPointerInstance()->read($bytes);
+               $data = $this->getPointerInstance()->read($bytes);
+
+               // Return data
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: data[%s]=%s - EXIT!', gettype($data), $data));
+               return $data;
        }
 
        /**
         * Rewinds to the beginning of the file
         *
-        * @return      $status         Status of this operation
+        * @return      void
         */
        public function rewind () {
                // Call pointer instance
-               return $this->getPointerInstance()->rewind();
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               $this->getPointerInstance()->rewind();
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
        }
 
        /**
@@ -717,9 +804,9 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         * @return      void
         * @throws      BadMethodCallException  If this method is called but file is not initialized
         */
-       public function analyzeFile () {
+       public function analyzeFileStructure () {
                // Make sure the file is initialized
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
                if (!$this->isFileInitialized()) {
                        // Bad method call
                        throw new BadMethodCallException('Method called but file is not initialized.');
@@ -736,9 +823,6 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
 
                // Then try to load all entries
                while ($this->valid()) {
-                       // Go to next entry
-                       $this->next();
-
                        // Get current entry
                        $current = $this->getCurrentBlock();
 
@@ -746,23 +830,28 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                         * If the block is empty, maybe the whole file is? This could mean
                         * that the file has been pre-allocated.
                         */
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current[]=%s', gettype($current)));
                        if (empty($current)) {
                                // Then skip this part
+                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current[]=%s is empty - CONTINUE!', gettype($current)));
                                continue;
                        }
 
-                       // Debug message
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('current()=%d', strlen($current)));
+                       // Go to next entry
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current()=%d', strlen($current)));
+                       $this->next();
                }
 
                // If the last read block is empty, check gaps
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: current()=%d', strlen($current)));
                if (empty($current)) {
                        // Output message
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Found a total of %s gaps.', count($this->gaps)));
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Found a total of %d gaps.', count($this->gaps)));
 
                        // Check gaps, if the whole file is empty.
-                       if ($this->isFileOnlyGaps()) {
+                       if ($this->isFileGapsOnly()) {
                                // Only gaps, so don't continue here.
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: File is gaps-only - EXIT!');
                                return;
                        }
 
@@ -777,7 +866,9 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                                $this->doRunDefragmentation();
                        }
                }
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
+
+               // Trace message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: EXIT!');
        }
 
        /**
@@ -877,11 +968,11 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         */
        public function valid () {
                // First calculate minimum block length
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
                $length = $this->getBlockInstance()->calculateMinimumBlockLength();
 
                // Short be more than zero!
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d', $length));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: length=%d', $length));
                if ($length < 1) {
                        // Throw UVE
                        throw new UnexpectedValueException(sprintf('length=%d is not expected', $length));
@@ -891,18 +982,19 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                $seekPosition = $this->key();
 
                // Then try to read it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d', $seekPosition));
                $data = $this->read($length);
 
                // If some bytes could be read, all is fine
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: data[%s]()=%d', gettype($data), strlen($data)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: data[%s]()=%d', gettype($data), strlen($data)));
                $isValid = ((is_string($data)) && (strlen($data) > 0));
 
                // Get header size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isValid=%d', intval($isValid)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isValid=%d', intval($isValid)));
                $headerSize = $this->getHeaderSize();
 
                // Is the seek position at or beyond the header?
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d,headerSize=%d', $seekPosition, $headerSize));
                if ($seekPosition >= $headerSize) {
                        // Seek back to old position
                        $isValid = ($isValid && $this->seek($seekPosition) === 0);
@@ -912,7 +1004,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                }
 
                // Return result
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isValid=%d - EXIT!', intval($isValid)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: isValid=%d - EXIT!', intval($isValid)));
                return $isValid;
        }
 
@@ -923,11 +1015,11 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
         */
        public function key () {
                // Call pointer instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-BINARY-FILE: CALLED!');
                $key = $this->getPointerInstance()->determineSeekPosition();
 
                // Return key
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: key[%s]=%d - EXIT!', gettype($key), $key));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: key[%s]=%d - EXIT!', gettype($key), $key));
                return $key;
        }
 
@@ -973,9 +1065,16 @@ abstract class BaseBinaryFile extends BaseAbstractFile {
                if ($length <= 0) {
                        // Throw IAE
                        throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
-               } elseif ($this->isFileOnlyGaps()) {
-                       // The first empty block is the first one right after the header
-                       return ($this->getHeaderSize() + 1);
+               } elseif ($this->isFileGapsOnly()) {
+                       /*
+                        * The first empty block is the 2nd one right after the header, so
+                        * one byte gap to the header.
+                        */
+                       $seekPosition = ($this->getHeaderSize() + 2);
+
+                       // Return position
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: seekPosition=%d - EXIT!', $seekPosition));
+                       return $seekPosition;
                }
 
                // @TODO Unfinished
index 07524bcabcd83ca3abcfc1b954c368601aa225aa..c220f47491695eb46b3bff6bb065dbbe8c15a3b7 100644 (file)
@@ -172,11 +172,11 @@ abstract class BaseAbstractFile extends BaseFrameworkSystem implements FilePoint
         */
        public function closeFile () {
                // Close down pointer instance as well by unsetting it
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: CALLED!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: CALLED!');
                $this->unsetPointerInstance();
 
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: EXIT!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-ABSTRACT-FILE: EXIT!');
        }
 
        /**
index 71d6d3ba60498db84cb3216fd63f83a35cdacbd0..c0d2aa2524a7c5e70f1f9abd54b22c99bf5705ee 100644 (file)
@@ -58,13 +58,17 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl
         */
        public final function __destruct() {
                // Is there a resource pointer? Then we have to close the file here!
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: this->fileObject[]=%s - DESTRUCTOR!', gettype($this->getFileObject())));
                if (is_object($this->getFileObject())) {
                        // Try to close a file
                        $this->closeFile();
-               } // END - if
+               }
 
                // Call the parent destructor
                parent::__destruct();
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: EXIT!');
        }
 
        /**
@@ -76,9 +80,8 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl
         * @throws      LogicException  If there is no object being set
         */
        public function closeFile () {
-               // Debug message
+               // Validate parameter
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: fileName=%s - CALLED!', $this->getFileObject()->getPathname()));
-
                if (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
@@ -87,14 +90,12 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl
                        throw new LogicException(sprintf('this->fileObject[]=%s is no object', gettype($this->getFileObject())));
                }
 
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: Closing file %s ...', $this->getFileObject()->getPathname()));
-
                // Close the file pointer by NULL-ing it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: Closing file %s ...', $this->getFileObject()->getPathname()));
                $this->resetFileObject();
 
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: EXIT!'));
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-IO: EXIT!');
        }
 
        /**
@@ -153,7 +154,7 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl
         */
        public function seek (int $offset, int $whence = SEEK_SET) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: offset=%d,whence=%d - CALLED!', $offset, $whence));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: offset=%d,whence=%d - CALLED!', $offset, $whence));
                if ($offset < 0) {
                        // Throw IAE
                        throw new InvalidArgumentException(sprintf('offset=%d is not valid', $offset));
@@ -163,7 +164,7 @@ abstract class BaseFileIo extends BaseFrameworkSystem implements FilePointer, Cl
                $status = $this->getFileObject()->fseek($offset, $whence);
 
                // Return status
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: status=%d - EXIT!', $status));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-IO: status=%d - EXIT!', $status));
                return $status;
        }
 
index 5e3c658ead37ac0cc59cfbce2cdd9050c483f7a3..7ac1dc1308aac352a3a491d2f15e4f0b1f54ad9a 100644 (file)
@@ -141,7 +141,7 @@ class FrameworkRawFileInputPointer extends BaseFileIo implements InputPointer {
         * @return      void
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public function analyzeFile () {
+       public function analyzeFileStructure () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index 20e127f26edeaab359200f616a0c11e26e0e817a..3fc1fc93ea631439d87eddfbfcc4867dd8a4686c 100644 (file)
@@ -122,7 +122,10 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         */
        public function read (int $bytes = 0) {
                // Some sanity checks
-               if (is_null($this->getFileObject())) {
+               if ($bytes < 0) {
+                       // Cannot be below zero
+                       throw new InvalidArgumentException(sprintf('bytes=%d is not valid', $bytes));
+               } elseif (is_null($this->getFileObject())) {
                        // Pointer not initialized
                        throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
                } elseif (!is_object($this->getFileObject())) {
@@ -151,7 +154,7 @@ class FrameworkTextFileInputPointer extends BaseFileIo implements InputPointer {
         * @return      void
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public function analyzeFile () {
+       public function analyzeFileStructure () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index 2805546ff35208997b53fef82e19eeab0b482ff7..3fa010894761998a4c33f0b1823043108c507a87 100644 (file)
@@ -63,6 +63,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         */
        public static final function createFrameworkFileInputOutputPointer (SplFileInfo $fileInstance) {
                // Some pre-sanity checks...
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileInstance[%s]=%s - CALLED!', get_class($fileInstance), $fileInstance));
                if (!FrameworkBootstrap::isReachableFilePath($fileInstance)) {
                        // File exists but cannot be read
                        throw new FileIoException($fileInstance, self::EXCEPTION_FILE_NOT_REACHABLE);
@@ -81,6 +82,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                $fileObject = $fileInstance->openFile('c+b');
 
                // Is it valid?
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileObject[]=%s', gettype($fileObject)));
                if ((is_null($fileObject)) || ($fileObject === false)) {
                        // Something bad happend
                        throw new FileIoException($fileInstance->getPathname(), self::EXCEPTION_FILE_POINTER_INVALID);
@@ -93,6 +95,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                $pointerInstance->setFileObject($fileObject);
 
                // Return the instance
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: pointerInstance=%s - EXIT!', $pointerInstance->__toString()));
                return $pointerInstance;
        }
 
@@ -103,8 +106,12 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         */
        public function readFromFile () {
                // Read data from the file pointer and return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
-               return $this->read(1024);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+               $data = $this->read(1024);
+
+               // Return data
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%d - EXIT!', gettype($data), $data));
+               return $data;
        }
 
        /**
@@ -121,8 +128,12 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                        throw new InvalidArgumentException('Parameter "dataStream" is empty');
                }
 
+               // Get length
+               $length = strlen($dataStream);
+
                // Write data to the file pointer and return written bytes
-               $status = $this->getFileObject()->fwrite($dataStream, strlen($dataStream));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Calling this->fileObject->fwrite(%s,%d) ...', $dataStream, $length));
+               $status = $this->getFileObject()->fwrite($dataStream, $length);
 
                // Return status
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
@@ -146,15 +157,13 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                } elseif (empty($dataStream)) {
                        // Empty dataStream
                        throw new InvalidArgumentException('Parameter "dataStream" is empty');
-               }
-
-               // First seek to it, if file size is larger than zero
-               if (($this->getFileSize() > 0 || $seekPosition > 0) && $this->seek($seekPosition) === -1) {
+               } elseif (($this->getFileSize() > 0 || $seekPosition > 0) && $this->seek($seekPosition) === -1) {
                        // Could not seek
                        throw new InvalidArgumentException(sprintf('Could not seek to seekPosition=%d', $seekPosition));
                }
 
                // Then write the data at that position
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: Calling this->writeToFile(%s) ...', $dataStream));
                $status = $this->writeToFile($dataStream);
 
                // Return status
@@ -168,12 +177,12 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         * @return      void
         */
        public function rewind () {
-               // Rewind the pointer
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+               /// Rewind the pointer
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
                $this->getFileObject()->rewind();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: EXIT!');
        }
 
        /**
@@ -186,7 +195,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         */
        public function seek (int $seekPosition, int $whence = SEEK_SET) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
                if ($seekPosition < 0) {
                        // Invalid seek position
                        throw new InvalidArgumentException(sprintf('seekPosition=%d is not valid.', $seekPosition));
@@ -196,7 +205,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                $status = $this->getFileObject()->fseek($seekPosition, $whence);
 
                // Return status
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: status[%s]=%d - EXIT!', gettype($status), $status));
                return $status;
        }
 
@@ -207,8 +216,12 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         */
        public function readLine () {
                // Read whole line
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
-               return $this->read();
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+               $data = $this->read();
+
+               // Return data
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%s - EXIT!', gettype($data), $data));
+               return $data;
        }
 
        /**
@@ -220,13 +233,13 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         */
        public function read (int $bytes = 0) {
                // Validatre parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: bytes=%d - CALLED!', $bytes));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: bytes=%d - CALLED!', $bytes));
                if ($bytes < 0) {
                        // Bytes cannot be lesser than zero
                        throw new InvalidArgumentException(sprintf('bytes=%d is not valid', $bytes));
                }
 
-               // Is $bytes set?
+               // Is $bytes bigger than zero?
                if ($bytes > 0) {
                        // Try to read given characters
                        $data = $this->getFileObject()->fread($bytes);
@@ -236,7 +249,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                }
 
                // Then return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%s - EXIT!', gettype($data), $data));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: data[%s]=%s - EXIT!', gettype($data), $data));
                return $data;
        }
 
@@ -248,7 +261,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         * @return      void
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public function analyzeFile () {
+       public function analyzeFileStructure () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
@@ -291,7 +304,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
         */
        public function getFileSize () {
                // Get file's data
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-INPUT-OUTPUT-POINTER: CALLED!');
                $fileData = $this->getFileObject()->fstat();
 
                // Make sure the required array key is there
@@ -301,7 +314,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP
                }
 
                // Return size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileData[size]=%d - EXIT!', $fileData['size']));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: fileData[size]=%d - EXIT!', $fileData['size']));
                return $fileData['size'];
        }
 
index e7453802acc5704342a1bcf2bc0a22fba876d5df..9cb509aa39f64f60ab4cee4a8082d487ed76a014 100644 (file)
@@ -107,7 +107,7 @@ class FrameworkRawFileOutputPointer extends BaseFileIo implements OutputPointer
         * @return      void
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public function analyzeFile () {
+       public function analyzeFileStructure () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index b4b8b8dadfc14bdd56f04455faa8d07b9b2075bf..2d5dbe256d31cbc6db26ac36b2baad93df57b7b1 100644 (file)
@@ -110,7 +110,7 @@ class FrameworkTextFileOutputPointer extends BaseFileIo implements OutputPointer
         * @return      void
         * @throws      UnsupportedOperationException   If this method is called
         */
-       public function analyzeFile () {
+       public function analyzeFileStructure () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index cd9648b96086ded25ef0cb882c95f200be2c9e77..79e1c054e33edd5c12cd72fd4403eda5f629a84c 100644 (file)
@@ -220,8 +220,8 @@ abstract class BaseIndex extends BaseFrameworkSystem {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-INDEX: created=%d', intval($created)));
                if (!$created) {
                        // Count all entries in file
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: Calling this->iteratorInstance->analyzeFile() ...');
-                       $this->getIteratorInstance()->analyzeFile();
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: Calling this->iteratorInstance->analyzeFileStructure() ...');
+                       $this->getIteratorInstance()->analyzeFileStructure();
                }
 
                // Trace message
@@ -235,9 +235,10 @@ abstract class BaseIndex extends BaseFrameworkSystem {
         */
        public function calculateMinimumBlockLength () {
                // Is it "cached"?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: CALLED!');
                if (self::$minimumBlockLength == 0) {
                        // Calulcate it
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: Calculating ...');
                        self::$minimumBlockLength = (
                                // Type
                                BaseBinaryFile::LENGTH_TYPE + strlen(chr(BaseBinaryFile::SEPARATOR_TYPE_POSITION)) +
@@ -247,7 +248,7 @@ abstract class BaseIndex extends BaseFrameworkSystem {
                }
 
                // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-INDEX: self::minimumBlockLength=%d - EXIT!', self::$minimumBlockLength));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-INDEX: self::minimumBlockLength=%d - EXIT!', self::$minimumBlockLength));
                return self::$minimumBlockLength;
        }
 
@@ -265,7 +266,7 @@ abstract class BaseIndex extends BaseFrameworkSystem {
         * Initializes counter for valid entries, arrays for damaged entries and
         * an array for gap seek positions. If you call this method on your own,
         * please re-analyze the file structure. So you are better to call
-        * analyzeFile() instead of this method.
+        * analyzeFileStructure() instead of this method.
         *
         * @return      void
         * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
index 24fb278033b8a1b2cfa0dbfbda16119ed5cd4317..2442fb55fa1093a68102df2dd11a2bd8b3fcd90f 100644 (file)
@@ -57,14 +57,14 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public final static function createFileIterator (Block $blockInstance) {
                // Get new instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: blockInstance=%s - CALLED!', $blockInstance->__toString()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: blockInstance=%s - CALLED!', $blockInstance->__toString()));
                $iteratorInstance = new FileIterator();
 
                // Set the instance here
                $iteratorInstance->setBlockInstance($blockInstance);
 
                // Return the prepared instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: iteratorInstance=%s - EXIT!', $iteratorInstance->__toString()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: iteratorInstance=%s - EXIT!', $iteratorInstance->__toString()));
                return $iteratorInstance;
        }
 
@@ -95,7 +95,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function current () {
                // Is condition given?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                if (!$this->valid()) {
                        // Throw BMCE
                        throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?');
@@ -105,7 +105,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $current = $this->getBlockInstance()->current();
 
                // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: current[]=%s - EXIT!', gettype($current)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: current[]=%s - EXIT!', gettype($current)));
                return $current;
        }
 
@@ -117,7 +117,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function key () {
                // Is condition given?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                if (!$this->valid()) {
                        // Throw BMCE
                        throw new BadMethodCallException('Current key cannot be valid, forgot to invoke valid()?');
@@ -127,7 +127,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $key = $this->getBlockInstance()->determineSeekPosition();
 
                // Return key
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: key[%s]=%s - EXIT!', gettype($key), $key));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: key[%s]=%s - EXIT!', gettype($key), $key));
                return $key;
        }
 
@@ -138,11 +138,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function next () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $this->getBlockInstance()->next();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -152,11 +152,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function rewind () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $this->getBlockInstance()->rewind();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -167,11 +167,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function valid () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $isValid = $this->getBlockInstance()->valid();
 
                // Return flag
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: isValid=%d - EXIT!', intval($isValid)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: isValid=%d - EXIT!', intval($isValid)));
                return $isValid;
        }
 
@@ -185,7 +185,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function seek (int $seekPosition, int $whence = SEEK_SET) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition=%d,whence=%d - CALLED!', $seekPosition, $whence));
                if ($seekPosition < 0) {
                        // Throw IAE
                        throw new InvalidArgumentException(sprintf('seekPosition=%d is not valid', $seekPosition));
@@ -195,7 +195,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $status = $this->getBlockInstance()->seek($seekPosition, $whence);
 
                // Return status
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: status=%d - EXIT!', intval($status)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: status=%d - EXIT!', intval($status)));
                return $status;
        }
 
@@ -206,11 +206,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function size () {
                // Call the block object
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $size = $this->getBlockInstance()->size();
 
                // Return size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
                return $size;
        }
 
@@ -222,7 +222,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function read (int $bytes = 0) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: bytes=%d - CALLED!', $bytes));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: bytes=%d - CALLED!', $bytes));
                if ($bytes < 0) {
                        // Throw IAE
                        throw new InvalidArgumentException(sprintf('bytes=%d is not valid', $bytes));
@@ -232,7 +232,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $data = $this->getBlockInstance()->read($bytes);
 
                // Return data
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
                return $data;
        }
 
@@ -243,13 +243,13 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         *
         * @return      void
         */
-       public function analyzeFile () {
+       public function analyzeFileStructure () {
                // Just call the block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
-               $this->getBlockInstance()->analyzeFile();
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               $this->getBlockInstance()->analyzeFileStructure();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -259,11 +259,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function isFileHeaderInitialized () {
                // Just call the block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $isInitialized = $this->getBlockInstance()->isFileHeaderInitialized();
 
                // Return flag
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: isInitialized=%d - EXIT!', intval($isInitialized)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: isInitialized=%d - EXIT!', intval($isInitialized)));
                return $isInitialized;
        }
 
@@ -274,11 +274,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function createFileHeader () {
                // Just call the block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $this->getBlockInstance()->createFileHeader();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -290,7 +290,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function preAllocateFile (string $type) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: type=%s - CALLED!', $type));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: type=%s - CALLED!', $type));
                if (empty($type)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "type" is empty');
@@ -300,24 +300,24 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $this->getBlockInstance()->preAllocateFile($type);
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
         * Initializes counter for valid entries, arrays for damaged entries and
         * an array for gap seek positions. If you call this method on your own,
         * please re-analyze the file structure. So you are better to call
-        * analyzeFile() instead of this method.
+        * analyzeFileStructure() instead of this method.
         *
         * @return      void
         */
        public function initCountersGapsArray () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $this->getBlockInstance()->initCountersGapsArray();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -327,11 +327,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public final function getHeaderSize () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $size = $this->getBlockInstance()->getHeaderSize();
 
                // Return size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
                return $size;
        }
 
@@ -343,11 +343,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public final function setHeaderSize (int $headerSize) {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: headerSize=%d - CALLED!', $headerSize));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: headerSize=%d - CALLED!', $headerSize));
                $this->getBlockInstance()->setHeaderSize($headerSize);
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -357,11 +357,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public final function getHeader () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $header = $this->getBlockInstance()->getHeader();
 
                // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: header()=%d - EXIT!', count($header)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: header()=%d - EXIT!', count($header)));
                return $header;
        }
 
@@ -373,11 +373,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public final function setHeader (array $header) {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: header()=%d - CALLED!', count($header)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: header()=%d - CALLED!', count($header)));
                $this->getBlockInstance()->setHeader($header);
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -387,11 +387,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function updateSeekPosition () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $this->getBlockInstance()->updateSeekPosition();
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -401,11 +401,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public final function getCounter () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $counter = $this->getBlockInstance()->getCounter();
 
                // Return counter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: counter=%d - EXIT!', $counter));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: counter=%d - EXIT!', $counter));
                return $counter;
        }
 
@@ -416,11 +416,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function getFileSize () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $size = $this->getBlockInstance()->getFileSize();
 
                // Return size
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: size=%d - EXIT!', $size));
                return $size;
        }
 
@@ -435,7 +435,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function writeData (int $seekPosition, string $data, bool $flushHeader = true) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition=%d,data(%d)=%s,flushHeader=%d - CALLED!', $seekPosition, strlen($data), $data, intval($flushHeader)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition=%d,data(%d)=%s,flushHeader=%d - CALLED!', $seekPosition, strlen($data), $data, intval($flushHeader)));
                if ($seekPosition < 0) {
                        // Throw IAE
                        throw new InvalidArgumentException(sprintf('seekPosition=%d is not valid', $seekPosition));
@@ -445,11 +445,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                }
 
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->blockInstance->writeData(%d,data()=%d,%d) ...', $seekPosition, strlen($data), intval($flushHeader)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->blockInstance->writeData(%d,data()=%d,%d) ...', $seekPosition, strlen($data), intval($flushHeader)));
                $this->getBlockInstance()->writeData($seekPosition, $data, $flushHeader);
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: EXIT!');
        }
 
        /**
@@ -462,7 +462,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function writeAtPosition (int $seekPosition, string $dataStream) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition=%d,dataStream(%d)=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream));
                if ($seekPosition < 0) {
                        // Invalid seek position
                        throw new InvalidArgumentException(sprintf('seekPosition=%d is not valid.', $seekPosition));
@@ -472,11 +472,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                }
 
                // Call iterated object's method
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->blockInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: Calling this->blockInstance->writeAtPosition(%d, %s) ...', $seekPosition, $dataStream));
                $status = $this->getBlockInstance()->writeAtPosition($seekPosition, $dataStream);
 
                // Return status
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: status[%s]=%d - EXIT!', gettype($status), $status));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: status[%s]=%d - EXIT!', gettype($status), $status));
                return $status;
        }
 
@@ -487,11 +487,11 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function getSeekPosition () {
                // Call block instance
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-ITERATOR: CALLED!');
                $seekPosition = $this->getBlockInstance()->getSeekPosition();
 
                // Return position
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition[%s]=%d - EXIT!', gettype($seekPosition), $seekPosition));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition[%s]=%d - EXIT!', gettype($seekPosition), $seekPosition));
                return $seekPosition;
        }
 
@@ -505,7 +505,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function writeValueToFile (string $groupId, $value) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: groupId=%s,value[]=%s - CALLED!', $groupId, gettype($value)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: groupId=%s,value[]=%s - CALLED!', $groupId, gettype($value)));
                if (empty($groupId)) {
                        // Throw IAE
                        throw new InvalidArgumentException('Parameter "groupId" is empty');
@@ -518,7 +518,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $data = $this->getBlockInstance()->writeValueToFile($groupId, $value);
 
                // Return data
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
                return $data;
        }
 
@@ -532,13 +532,13 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function writeDataToFreeGap (string $groupId, string $hash, string $encoded) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: groupId=%s,hash=%s,encoded()=%d - CALLED!', $groupId, $hash, strlen($encoded)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: groupId=%s,hash=%s,encoded()=%d - CALLED!', $groupId, $hash, strlen($encoded)));
 
                // Call block instance
                $data = $this->getBlockInstance()->writeDataToFreeGap($groupId, $hash, $encoded);
 
                // Return data
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: data[]=%s - EXIT!', gettype($data)));
                return $data;
        }
 
@@ -552,7 +552,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
         */
        public function searchNextGap (int $length) {
                // Validate parameter
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: length=%d - CALLED!', $length));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: length=%d - CALLED!', $length));
                if ($length <= 0) {
                        // Throw IAE
                        throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
@@ -562,7 +562,7 @@ class FileIterator extends BaseIterator implements SeekableWritableFileIterator
                $seekPosition = $this->getBlockInstance()->searchNextGap($length);
 
                // Return position
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition[%s]=%d - EXIT!', gettype($seekPosition), $seekPosition));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-ITERATOR: seekPosition[%s]=%d - EXIT!', gettype($seekPosition), $seekPosition));
                return $seekPosition;
        }
 
index 859eebd885f5d7476a1eda9cbc33a839b9c29dbf..63686de9f14a0640f8876a43b16670ff11cd2477 100644 (file)
@@ -269,8 +269,8 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: created=%d', intval($created)));
                if (!$created) {
                        // Count all entries in file
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->analyzeFile() ...');
-                       $this->getIteratorInstance()->analyzeFile();
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->iteratorInstance->analyzeFileStructure() ...');
+                       $this->getIteratorInstance()->analyzeFileStructure();
                }
 
                /*
@@ -542,9 +542,10 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
         */
        public function calculateMinimumBlockLength () {
                // Is the value "cached"?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
                if (self::$minimumBlockLength == 0) {
                        // Calulcate it
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calculating ...');
                        self::$minimumBlockLength =
                                // Length of entry group
                                BaseBinaryFile::LENGTH_GROUP + strlen(chr(BaseBinaryFile::SEPARATOR_GROUP_HASH)) +
@@ -555,7 +556,7 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
                }
 
                // Return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: self::minimumBlockLength=%d - EXIT!', self::$minimumBlockLength));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: self::minimumBlockLength=%d - EXIT!', self::$minimumBlockLength));
                return self::$minimumBlockLength;
        }
 
@@ -563,7 +564,7 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile {
         * Initializes counter for valid entries, arrays for damaged entries and
         * an array for gap seek positions. If you call this method on your own,
         * please re-analyze the file structure. So you are better to call
-        * analyzeFile() instead of this method.
+        * analyzeFileStructure() instead of this method.
         *
         * @return      void
         * @throws      UnsupportedOperationException   This method is not (and maybe never will be) supported
index 5c25324b09d69e2900a2341f4f58a93f8714c7a1..af107eb98a9194f0faaf1b44f678161fd528f87c 100644 (file)
@@ -53,7 +53,7 @@ interface Block extends FrameworkInterface {
         * Initializes counter for valid entries, arrays for damaged entries and
         * an array for gap seek positions. If you call this method on your own,
         * please re-analyze the file structure. So you are better to call
-        * analyzeFile() instead of this method.
+        * analyzeFileStructure() instead of this method.
         *
         * @return      void
         */
index 728a3457266998c2ea1b348482fb82e0e9ff629a..21ad59ef416c4b046d9fa17772b4537b14860cf4 100644 (file)
@@ -59,7 +59,7 @@ interface SeekableWritableFileIterator extends SeekableIterator {
         *
         * @return      void
         */
-       function analyzeFile ();
+       function analyzeFileStructure ();
 
        /**
         * Checks whether the file header is initialized
@@ -87,7 +87,7 @@ interface SeekableWritableFileIterator extends SeekableIterator {
         * Initializes counter for valid entries, arrays for damaged entries and
         * an array for gap seek positions. If you call this method on your own,
         * please re-analyze the file structure. So you are better to call
-        * analyzeFile() instead of this method.
+        * analyzeFileStructure() instead of this method.
         *
         * @return      void
         */