* @return void
*/
function preAllocateFile ($type);
+
+ /**
+ * 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.
+ *
+ * @return void
+ */
+ function initCountersGapsArray ();
+
+ /**
+ * Getter for header size
+ *
+ * @return $totalEntries Size of file header
+ */
+ function getHeaderSize ();
+
+ /**
+ * Setter for header size
+ *
+ * @param $headerSize Size of file header
+ * @return void
+ */
+ function setHeaderSize ($headerSize);
}
// [EOF]
*
* @return void
*/
- protected function initCountersGapsArray () {
+ public function initCountersGapsArray () {
// Init counter and seek position
$this->setCounter(0);
$this->setSeekPosition(0);
* @param $headerSize Size of file header
* @return void
*/
- protected final function setHeaderSize ($headerSize) {
+ public final function setHeaderSize ($headerSize) {
// Set it
$this->headerSize = $headerSize;
}
protected function __construct ($className) {
// Call parent constructor
parent::__construct($className);
-
- // Calculate header size
- $this->setHeaderSize(
- strlen(self::INDEX_MAGIC) +
- strlen(chr(BaseFile::SEPARATOR_HEADER_DATA)) +
- BaseFile::LENGTH_COUNT +
- strlen(chr(BaseFile::SEPARATOR_HEADER_ENTRIES))
- );
-
- // Init counters and gaps array
- $this->initCountersGapsArray();
}
/**
$this->getIteratorInstance()->rewind();
// Then read it (see constructor for calculation)
- $data = $this->getIteratorInstance()->read($this->getHeaderSize());
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getHeaderSize()));
+ $data = $this->getIteratorInstance()->read($this->getIteratorInstance()->getHeaderSize());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getIteratorInstance()->getHeaderSize()));
// Have all requested bytes been read?
- assert(strlen($data) == $this->getHeaderSize());
+ assert(strlen($data) == $this->getIteratorInstance()->getHeaderSize());
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Last character must be the separator
// Set iterator here
$this->setIteratorInstance($iteratorInstance);
+ // Calculate header size
+ $this->getIteratorInstance()->setHeaderSize(
+ strlen(self::INDEX_MAGIC) +
+ strlen(chr(BaseFile::SEPARATOR_HEADER_DATA)) +
+ BaseFile::LENGTH_COUNT +
+ strlen(chr(BaseFile::SEPARATOR_HEADER_ENTRIES))
+ );
+
+ // Init counters and gaps array
+ $this->getIteratorInstance()->initCountersGapsArray();
+
// Is the file's header initialized?
if (!$this->getIteratorInstance()->isFileHeaderInitialized()) {
// No, then create it (which may pre-allocate the index)
// Just call the block instance
$this->getBlockInstance()->preAllocateFile($type);
}
+
+ /**
+ * 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.
+ *
+ * @return void
+ */
+ public function initCountersGapsArray () {
+ // Call block instance
+ $this->getBlockInstance()->initCountersGapsArray();
+ }
+
+ /**
+ * Getter for header size
+ *
+ * @return $totalEntries Size of file header
+ */
+ public final function getHeaderSize () {
+ // Call block instance
+ return $this->getBlockInstance()->getHeaderSize();
+ }
+
+ /**
+ * Setter for header size
+ *
+ * @param $headerSize Size of file header
+ * @return void
+ */
+ public final function setHeaderSize ($headerSize) {
+ // Call block instance
+ $this->getBlockInstance()->setHeaderSize($headerSize);
+ }
}
// [EOF]
protected function __construct ($className) {
// Call parent constructor
parent::__construct($className);
-
- // Calculate header size
- $this->setHeaderSize(
- strlen(self::STACK_MAGIC) +
- strlen(chr(BaseFile::SEPARATOR_HEADER_DATA)) +
- BaseFile::LENGTH_COUNT +
- strlen(chr(BaseFile::SEPARATOR_HEADER_DATA)) +
- BaseFile::LENGTH_POSITION +
- strlen(chr(BaseFile::SEPARATOR_HEADER_ENTRIES))
- );
-
- // Init counters and gaps array
- $this->initCountersGapsArray();
}
/**
$this->getIteratorInstance()->rewind();
// Then read it (see constructor for calculation)
- $data = $this->getIteratorInstance()->read($this->getHeaderSize());
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getHeaderSize()));
+ $data = $this->getIteratorInstance()->read($this->getIteratorInstance()->getHeaderSize());
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Read %d bytes (%d wanted).', __METHOD__, __LINE__, strlen($data), $this->getIteratorInstance()->getHeaderSize()));
// Have all requested bytes been read?
- assert(strlen($data) == $this->getHeaderSize());
+ assert(strlen($data) == $this->getIteratorInstance()->getHeaderSize());
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] Passed assert().', __METHOD__, __LINE__));
// Last character must be the separator
// Set iterator here
$this->setIteratorInstance($iteratorInstance);
+ // Calculate header size
+ $this->getIteratorInstance()->setHeaderSize(
+ strlen(self::STACK_MAGIC) +
+ strlen(chr(BaseFile::SEPARATOR_HEADER_DATA)) +
+ BaseFile::LENGTH_COUNT +
+ strlen(chr(BaseFile::SEPARATOR_HEADER_DATA)) +
+ BaseFile::LENGTH_POSITION +
+ strlen(chr(BaseFile::SEPARATOR_HEADER_ENTRIES))
+ );
+
+ // Init counters and gaps array
+ $this->getIteratorInstance()->initCountersGapsArray();
+
// Is the file's header initialized?
if (!$this->getIteratorInstance()->isFileHeaderInitialized()) {
// No, then create it (which may pre-allocate the stack)