*/
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));
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));
}