mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
fix SharpCompressStream BufferSize setter and Seek as well
the BufferSize setter was completely broken and trashed the `_internalPosition` value on set, for `Seek` this is just an off-by-one fix allowing seeking to immediately past the last byte in the buffer
This commit is contained in:
@@ -79,7 +79,7 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
{
|
||||
if (value < 0 || value > _bufferedLength)
|
||||
throw new ArgumentOutOfRangeException(nameof(value));
|
||||
_internalPosition = value;
|
||||
_internalPosition = _internalPosition - _bufferPosition + value;
|
||||
_bufferPosition = value;
|
||||
ValidateBufferState(); // Add here
|
||||
}
|
||||
@@ -291,7 +291,7 @@ public class SharpCompressStream : Stream, IStreamStack
|
||||
|
||||
long bufferPos = _internalPosition - _bufferPosition;
|
||||
|
||||
if (targetPos >= bufferPos && targetPos < bufferPos + _bufferedLength)
|
||||
if (targetPos >= bufferPos && targetPos <= bufferPos + _bufferedLength)
|
||||
{
|
||||
_bufferPosition = (int)(targetPos - bufferPos); //repoint within the buffer
|
||||
_internalPosition = targetPos;
|
||||
|
||||
Reference in New Issue
Block a user