]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/stacker/file/class_BaseFileStack.php
Moved even more code to BaseFile where a much better place is for it (clear encapsula...
[core.git] / inc / classes / main / stacker / file / class_BaseFileStack.php
index 1ceda761f28f0522a590fce0aa5ba5c8c381b0b6..9219ecc3d132f4458e9e2fe79da64e37642e429b 100644 (file)
@@ -55,6 +55,7 @@ class BaseFileStack extends BaseStacker {
         * Reads the file header
         *
         * @return      void
+        * @todo        To hard assertions here, better rewrite them to exceptions
         */
        protected function readFileHeader () {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
@@ -150,43 +151,6 @@ class BaseFileStack extends BaseStacker {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
        }
 
-       /**
-        * Analyzes entries in stack file. This will count all found (and valid)
-        * entries, mark invalid as damaged and count gaps ("fragmentation"). If
-        * only gaps are found, the file is considered as "virgin" (no entries).
-        *
-        * @return      void
-        */
-       private function analyzeFile () {
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
-
-               // Make sure the file is initialized
-               assert($this->isFileInitialized());
-
-               // Init counters and gaps array
-               $this->initCountersGapsArray();
-
-               // Output message (as this may take some time)
-               self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Analyzing file structure ... (this may take some time)', __METHOD__, __LINE__));
-
-               // First rewind to the begining
-               $this->getIteratorInstance()->rewind();
-
-               // Then try to load all entries
-               while ($this->getIteratorInstance()->valid()) {
-                       // Go to next entry
-                       $this->getIteratorInstance()->next();
-
-                       // Get current entry
-                       $current = $this->getIteratorInstance()->current();
-
-                       // Simply output it
-                       self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] current=%s', __METHOD__, __LINE__, print_r($current, TRUE)));
-               } // END - while
-
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
-       }
-
        /**
         * Initializes this file-based stack.
         *
@@ -197,10 +161,10 @@ class BaseFileStack extends BaseStacker {
         */
        protected function initFileStack ($fileName, $type) {
                // Get a stack file instance
-               $fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileName));
+               $fileInstance = ObjectFactory::createObjectByConfiguredName('stack_file_class', array($fileName, $this));
 
                // Get iterator instance
-               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_io_iterator_class', array($fileInstance, $this));
+               $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_io_iterator_class', array($fileInstance));
 
                // Is the instance implementing the right interface?
                assert($iteratorInstance instanceof SeekableWritableFileIterator);
@@ -221,7 +185,7 @@ class BaseFileStack extends BaseStacker {
                $this->readFileHeader();
 
                // Count all entries in file
-               $this->analyzeFile();
+               $this->getIteratorInstance()->analyzeFile();
 
                /*
                 * Get stack index instance. This can be used for faster