X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=inc%2Fclasses%2Fmain%2Ffile_directories%2Fclass_BaseFile.php;h=fb60162627ffd747a23ac92c928ffebe15e152a7;hb=0af07e30d2e346b21cbb57b53c7550ce93baac06;hp=7816e86645708ea95dce41107b50860ae0409767;hpb=4af01023fc4b9ffc4c7174264dbff53966aecc91;p=core.git diff --git a/inc/classes/main/file_directories/class_BaseFile.php b/inc/classes/main/file_directories/class_BaseFile.php index 7816e866..fb601626 100644 --- a/inc/classes/main/file_directories/class_BaseFile.php +++ b/inc/classes/main/file_directories/class_BaseFile.php @@ -36,6 +36,9 @@ class BaseFile extends BaseFrameworkSystem { protected function __construct ($className) { // Call parent constructor parent::__construct($className); + + // Init counters and gaps array + $this->initCountersGapsArray(); } /** @@ -58,7 +61,6 @@ class BaseFile extends BaseFrameworkSystem { * @throws UnsupportedOperationException If this method is called */ public final function getPointer () { - self::createDebugInstance(__CLASS__)->debugOutput('Unhandled ' . strlen($data) . ' bytes in this stream.'); throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } @@ -193,6 +195,43 @@ class BaseFile extends BaseFrameworkSystem { public final function isEndOfFileReached () { return $this->getPointerInstance()->isEndOfFileReached(); } + + /** + * Analyzes entries in index 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 + */ + public 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->rewind(); + + // Then try to load all entries + while ($this->valid()) { + // Go to next entry + $this->next(); + + // Get current entry + $current = $this->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__)); + } } // [EOF]