-
Notifications
You must be signed in to change notification settings - Fork 510
Expose SharpCompressStream to allow ringbuffer to be used on non-seekable streams #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -485,6 +485,31 @@ using (var archive = ZipArchive.CreateArchive()) | |||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ### Buffered Forward-Only Streams | ||||||
|
|
||||||
| `SharpCompressStream` can wrap streams with buffering for forward-only scenarios: | ||||||
|
|
||||||
| ```csharp | ||||||
| // Wrap a non-seekable stream with buffering | ||||||
| using (var bufferedStream = new SharpCompressStream(rawStream)) | ||||||
|
||||||
| using (var bufferedStream = new SharpCompressStream(rawStream)) | |
| using (var bufferedStream = SharpCompressStream.Create(rawStream)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,19 @@ | |
|
|
||
| namespace SharpCompress.IO; | ||
|
|
||
adamhathcock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| internal partial class SharpCompressStream : Stream, IStreamStack | ||
| /// <summary> | ||
| /// Stream wrapper that provides optional ring-buffered reading for non-seekable | ||
| /// or forward-only streams, enabling limited backward seeking required by some | ||
| /// decompressors and archive formats. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// In most cases, callers should obtain an instance via the static | ||
| /// <c>SharpCompressStream.Create(...)</c> methods rather than constructing this | ||
| /// class directly. The <c>Create</c> methods select an appropriate configuration | ||
| /// (such as passthrough vs buffered mode and buffer size) for the underlying | ||
| /// stream and usage scenario. | ||
| /// </remarks> | ||
| public partial class SharpCompressStream : Stream, IStreamStack | ||
|
||
| { | ||
| public virtual Stream BaseStream() => stream; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Buffered example uses the direct constructor, which doesn't enable ring buffering
SharpCompressStream(Stream)doesn't allocate a ring buffer, so the example won't provide the buffering described in the text. UseSharpCompressStream.Create(...)(or pass a buffer size) to ensure the wrapper is configured for non-seekable buffering.