leave stream open

This commit is contained in:
Adam Hathcock
2026-02-05 09:34:54 +00:00
parent 778a930266
commit 3fb8387419
2 changed files with 13 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ internal sealed partial class SeekableSharpCompressStream : SharpCompressStream
/// </summary>
public override bool ThrowOnDispose { get; set; }
public SeekableSharpCompressStream(Stream stream)
public SeekableSharpCompressStream(Stream stream, bool leaveStreamOpen = false)
: base(Null, true, false, null)
{
if (stream is null)
@@ -33,6 +33,8 @@ internal sealed partial class SeekableSharpCompressStream : SharpCompressStream
{
throw new ArgumentException("Stream must be seekable", nameof(stream));
}
LeaveStreamOpen = leaveStreamOpen;
_stream = stream;
}

View File

@@ -28,10 +28,18 @@ internal partial class SharpCompressStream
if (underlying.CanSeek)
{
// Create SeekableSharpCompressStream that preserves LeaveStreamOpen
return new SeekableSharpCompressStream(underlying);
return new SeekableSharpCompressStream(
underlying,
sharpCompressStream.LeaveStreamOpen
);
}
// Non-seekable underlying stream - wrap with rolling buffer
return new SharpCompressStream(underlying, true, false, rewindableBufferSize);
return new SharpCompressStream(
underlying,
sharpCompressStream.LeaveStreamOpen,
false,
rewindableBufferSize
);
}
// Not passthrough - return as-is
return sharpCompressStream;