Skip to content

Commit

Permalink
we need to update the datasize everythime ->data is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
cod3beat committed Jun 19, 2024
1 parent adbef91 commit e0538fc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/LzwStreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public function stream_close()
if (file_exists($this->tmp2)) unlink($this->tmp2);
} else {
$this->data = null;
$this->dataSize = 0;
}
}

Expand Down Expand Up @@ -339,6 +340,7 @@ public function stream_write($data)
$postfix = substr($this->data, ($this->pointer + $count));
$this->data = $prefix.$data.$postfix;
$this->pointer += $count;
$this->dataSize = strlen($this->data);

return $count;
}
Expand Down Expand Up @@ -396,6 +398,7 @@ public function stream_truncate($new_size)
} elseif ($new_size < $actual_data_size) {
if ($this->tmp === null) {
$this->data = substr($this->data, 0, $new_size);
$this->dataSize = strlen($this->data);
$this->writtenBytes = $new_size;
} else {
$fp = fopen($this->tmp, 'w'.(strpos($this->mode, 'b') !== 0
Expand Down

0 comments on commit e0538fc

Please sign in to comment.