From af45f18ec6af6f2a7a4734b477343b58a28c79ef Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 18 May 2014 00:42:05 +0200 Subject: [PATCH] Continued with file-based stacks: - used writeAtPosition() instead of seek() - added debug line - updated documentation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- contrib/file_stack/format.txt | 4 ++-- inc/classes/main/file_directories/class_BaseFileIo.php | 4 ++-- inc/classes/main/stacker/file/class_BaseFileStack.php | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/contrib/file_stack/format.txt b/contrib/file_stack/format.txt index 637baf6f..9d88c78e 100644 --- a/contrib/file_stack/format.txt +++ b/contrib/file_stack/format.txt @@ -15,7 +15,7 @@ Continued: Purpose: | hash 0 | separator | name 0 | entry 0 | hash n | separator | name n | entry n | EOF | ---------+--------+-----------+--------+------------+--------+-----------+--------+------------+-----+ -Bytes: | ??? | 1 | 10 | 1-n (pack) | ??? | 1 | 10 | 1-n (pack) | 1 | +Bytes: | 64 | 1 | 10 | 1-n (pack) | 64 | 1 | 10 | 1-n (pack) | 1 | ---------+--------+-----------+--------+------------+--------+-----------+--------+------------+-----+ Example: | abc | ??? | foo | ... | abc | ??? | bar | ... | EOF | @@ -25,7 +25,7 @@ Explanations: separator - Serves to detect end of strings with unknown/flexible length count - Total amount of entries (not deleted) encoded in hexa-decimal position - Seek position of current entry (which current() will give) - hash X - Hash sum of entry X + hash X - Hash sum of entry X (SHA 256) name X - Name of stack the entries belongs in entry X - The actual data, compressed with pack() EOF - End-of-file character diff --git a/inc/classes/main/file_directories/class_BaseFileIo.php b/inc/classes/main/file_directories/class_BaseFileIo.php index e4a076f9..cce45b80 100644 --- a/inc/classes/main/file_directories/class_BaseFileIo.php +++ b/inc/classes/main/file_directories/class_BaseFileIo.php @@ -144,7 +144,7 @@ class BaseFileIo extends BaseFrameworkSystem { $status = fseek($this->getPointer(), $offset, $whence); // Return status - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] status=%s', __METHOD__, __LINE__, $status)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] status=%d', __METHOD__, __LINE__, $status)); return $status; } @@ -161,7 +161,7 @@ class BaseFileIo extends BaseFrameworkSystem { // Seek to end $seekStatus = $this->seek(0, SEEK_END); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekStatus=%s', __METHOD__, __LINE__, $seekStatus)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus)); // Get position again (which is the end of the file) $size = $this->getSeekPosition(); diff --git a/inc/classes/main/stacker/file/class_BaseFileStack.php b/inc/classes/main/stacker/file/class_BaseFileStack.php index 6f551827..68d95fa1 100644 --- a/inc/classes/main/stacker/file/class_BaseFileStack.php +++ b/inc/classes/main/stacker/file/class_BaseFileStack.php @@ -277,7 +277,10 @@ class BaseFileStack extends BaseStacker { /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekPosition=%s', __METHOD__, __LINE__, $seekPosition)); // Now seek to the position - $this->getIteratorInstance()->seek($seekPosition); + $seekStatus = $this->getIteratorInstance()->writeAtPosition($seekPosition, chr(0)); + + // Did it work? + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus)); /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d:] EXIT!', __METHOD__, __LINE__)); } -- 2.30.2