$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
}
/**
- * 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;
}
/**
* @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;
}
* @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;
}
* @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;
}
* @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!');
}
/**
- * 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;
}
/**
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
*
// 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
*/
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;
}
/**
* @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;
}
/**
*
* @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!');
}
/**
* @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.');
// Then try to load all entries
while ($this->valid()) {
- // Go to next entry
- $this->next();
-
// Get current entry
$current = $this->getCurrentBlock();
* 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;
}
$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!');
}
/**
*/
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));
$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);
}
// 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;
}
*/
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;
}
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
*/
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!');
}
/**
*/
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!');
}
/**
* @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);
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!');
}
/**
*/
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));
$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;
}
* @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);
}
*/
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())) {
* @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);
}
*/
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);
$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);
$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;
}
*/
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;
}
/**
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));
} 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
* @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!');
}
/**
*/
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));
$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;
}
*/
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;
}
/**
*/
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);
}
// 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;
}
* @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);
}
*/
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
}
// 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'];
}
* @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);
}
* @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);
}
/* 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
*/
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)) +
}
// 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;
}
* 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
*/
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;
}
*/
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()?');
$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;
}
*/
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()?');
$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;
}
*/
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!');
}
/**
*/
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!');
}
/**
*/
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;
}
*/
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));
$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;
}
*/
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;
}
*/
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));
$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;
}
*
* @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!');
}
/**
*/
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;
}
*/
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!');
}
/**
*/
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');
$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!');
}
/**
*/
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;
}
*/
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!');
}
/**
*/
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;
}
*/
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!');
}
/**
*/
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!');
}
/**
*/
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;
}
*/
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;
}
*/
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));
}
// 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!');
}
/**
*/
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));
}
// 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;
}
*/
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;
}
*/
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');
$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;
}
*/
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;
}
*/
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));
$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;
}
/* 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();
}
/*
*/
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)) +
}
// 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;
}
* 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
* 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
*/
*
* @return void
*/
- function analyzeFile ();
+ function analyzeFileStructure ();
/**
* Checks whether the file header is initialized
* 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
*/