use Org\Mxchange\CoreFramework\Factory\Stack\File\FileStackIndexFactory;
use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\File\BaseBinaryFile;
+use Org\Mxchange\CoreFramework\Filesystem\File\BinaryFile;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
use Org\Mxchange\CoreFramework\Stack\BaseStacker;
use Org\Mxchange\CoreFramework\Traits\Index\IndexableTrait;
// Last character must be the separator
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: data(-1)=%s', dechex(ord(substr($data, -1, 1)))));
- if (substr($data, -1, 1) !== chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)) {
+ if (substr($data, -1, 1) !== chr(BinaryFile::SEPARATOR_HEADER_ENTRIES)) {
// Not valid separator
throw new UnexpectedValueException(sprintf('data=%s does not have separator=%s at the end.',
$data,
- BaseBinaryFile::SEPARATOR_HEADER_ENTRIES
+ BinaryFile::SEPARATOR_HEADER_ENTRIES
));
}
* 1 => total entries
* 2 => current seek position
*/
- $header = explode(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA), $data);
+ $header = explode(chr(BinaryFile::SEPARATOR_HEADER_DATA), $data);
// Check if the array has only 3 elements
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: header(%d)=%s', count($header), print_r($header, true)));
}
// Check length of count and seek position
- if (strlen($header[1]) != BaseBinaryFile::LENGTH_COUNT) {
+ if (strlen($header[1]) != BinaryFile::LENGTH_COUNT) {
// Count length not valid
throw new UnexpectedValueException(sprintf('header[1](%d)=%s is not expected %d length',
strlen($header[1]),
$header[1],
- BaseBinaryFile::LENGTH_COUNT
+ BinaryFile::LENGTH_COUNT
));
- } elseif (strlen($header[1]) != BaseBinaryFile::LENGTH_POSITION) {
+ } elseif (strlen($header[1]) != BinaryFile::LENGTH_POSITION) {
// Position length not valid
throw new UnexpectedValueException(sprintf('header[2](%d)=%s is not expected %d length',
strlen($header[1]),
$header[1],
- BaseBinaryFile::LENGTH_POSITION
+ BinaryFile::LENGTH_POSITION
));
}
StackableFile::STACK_MAGIC,
// Separator magic<->count
- chr(BaseBinaryFile::SEPARATOR_HEADER_DATA),
+ chr(BinaryFile::SEPARATOR_HEADER_DATA),
// Padded total entries
- str_pad(StringUtils::dec2hex($this->getIteratorInstance()->getBinaryFileInstance()->getCounter()), BaseBinaryFile::LENGTH_COUNT, '0', STR_PAD_LEFT),
+ str_pad(StringUtils::dec2hex($this->getIteratorInstance()->getBinaryFileInstance()->getCounter()), BinaryFile::LENGTH_COUNT, '0', STR_PAD_LEFT),
// Separator count<->seek position
- chr(BaseBinaryFile::SEPARATOR_HEADER_DATA),
+ chr(BinaryFile::SEPARATOR_HEADER_DATA),
// Padded seek position
- str_pad(StringUtils::dec2hex($this->getIteratorInstance()->getBinaryFileInstance()->getSeekPosition(), 2), BaseBinaryFile::LENGTH_POSITION, '0', STR_PAD_LEFT),
+ str_pad(StringUtils::dec2hex($this->getIteratorInstance()->getBinaryFileInstance()->getSeekPosition(), 2), BinaryFile::LENGTH_POSITION, '0', STR_PAD_LEFT),
// Separator position<->entries
- chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES)
+ chr(BinaryFile::SEPARATOR_HEADER_ENTRIES)
);
// Write it to disk (header is always at seek position 0)
// Calculate header size
$headerSize = (
strlen(StackableFile::STACK_MAGIC) +
- strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) +
- BaseBinaryFile::LENGTH_COUNT +
- strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) +
- BaseBinaryFile::LENGTH_POSITION +
- strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES))
+ strlen(chr(BinaryFile::SEPARATOR_HEADER_DATA)) +
+ BinaryFile::LENGTH_COUNT +
+ strlen(chr(BinaryFile::SEPARATOR_HEADER_DATA)) +
+ BinaryFile::LENGTH_POSITION +
+ strlen(chr(BinaryFile::SEPARATOR_HEADER_ENTRIES))
);
// Setting 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)) +
+ BinaryFile::LENGTH_GROUP + strlen(chr(BinaryFile::SEPARATOR_GROUP_HASH)) +
// Hash + value
- self::getHashLength() + strlen(chr(BaseBinaryFile::SEPARATOR_HASH_VALUE)) + 1 +
+ self::getHashLength() + strlen(chr(BinaryFile::SEPARATOR_HASH_VALUE)) + 1 +
// Final separator
- strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES));
+ strlen(chr(BinaryFile::SEPARATOR_ENTRIES));
}
// Return it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash=%s,encoded()=%d - CALLED!', $stackName, $hash, strlen($encoded)));
$rawData = sprintf('%s%s%s%s%s',
$stackName,
- BaseBinaryFile::SEPARATOR_GROUP_HASH,
+ BinaryFile::SEPARATOR_GROUP_HASH,
hex2bin($hash),
- BaseBinaryFile::SEPARATOR_HASH_VALUE,
+ BinaryFile::SEPARATOR_HASH_VALUE,
$encoded
);