*
* @return void
*/
- private function flushFileHeader () {
+ protected function flushFileHeader () {
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] CALLED!', __METHOD__, __LINE__));
// Put all informations together
- $header = sprintf('%s%s',
+ $header = sprintf('%s%s%s%s',
// Magic
self::INDEX_MAGIC,
- // Separator position<->entries
+ // Separator header data
+ chr(self::SEPARATOR_HEADER_DATA),
+
+ // Total entries
+ str_pad($this->dec2hex($this->getCounter()), self::LENGTH_COUNT, '0', STR_PAD_LEFT),
+
+ // Separator header<->entries
chr(self::SEPARATOR_HEADER_ENTRIES)
);
// Write it to disk (header is always at seek position 0)
- $this->writeData(0, $header);
+ $this->writeData(0, $header, FALSE);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__));
}
assert($this->isFileInitialized());
// Init counters and gaps array
- $this->initGapsArray();
+ $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()->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__));
}
+ /**
+ * Calculates minimum length for one entry
+ *
+ * @return $length Minimum length for one entry
+ */
+ protected function caluclateMinimumFileEntryLength () {
+ // Calulcate it
+ // @TODO Not finished yet
+ $length = 0;
+
+ // Return it
+ return $length;
+ }
+
/**
* Initializes this index
*
* @param $fileName File name of this index
* @return void
+ * @todo Currently the index file is not cached, please implement a memory-handling class and if enough RAM is found, cache the whole index file.
*/
protected function initIndex ($fileName) {
// Append index file extension
$fileName .= $this->getConfigInstance()->getConfigEntry('index_extension');
// Get a file i/o pointer instance for index file
- $pointerInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_output_class', array($fileName));
+ $fileInstance = ObjectFactory::createObjectByConfiguredName('index_file_class', array($fileName));
// Get iterator instance
- $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_io_iterator_class', array($pointerInstance));
+ $iteratorInstance = ObjectFactory::createObjectByConfiguredName('file_io_iterator_class', array($fileInstance));
// Is the instance implementing the right interface?
assert($iteratorInstance instanceof SeekableWritableFileIterator);