From 45ac696024e307b411a6185abefef5af0d8c5f5a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 7 Dec 2020 12:01:32 +0100 Subject: [PATCH] Continued: - seeking to position zero within a zero-sized file doesn't make sense MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../io/class_FrameworkFileInputOutputPointer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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)); } -- 2.39.5