From: Roland Häder Date: Mon, 7 Dec 2020 11:01:32 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=45ac696024e307b411a6185abefef5af0d8c5f5a;p=core.git Continued: - seeking to position zero within a zero-sized file doesn't make sense Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php b/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php index 0f58453c..4e79954f 100644 --- a/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php +++ b/framework/main/classes/file_directories/io/class_FrameworkFileInputOutputPointer.php @@ -139,7 +139,7 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP */ public function writeAtPosition (int $seekPosition, string $dataStream) { // Validate parameter - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: seekPosition=%d,dataStream()=%s - CALLED!', $seekPosition, strlen($dataStream), $dataStream)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-INPUT-OUTPUT-POINTER: 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)); @@ -148,8 +148,8 @@ class FrameworkFileInputOutputPointer extends BaseFileIo implements InputOutputP throw new InvalidArgumentException('Parameter "dataStream" is empty'); } - // First seek to it - if (!$this->seek($seekPosition)) { + // First seek to it, if file size is larger than zero + if ($this->getFileSize() > 0 && !$this->seek($seekPosition)) { // Could not seek throw new InvalidArgumentException(sprintf('Could not seek to seekPosition=%d', $seekPosition)); }