zstd support for tar (can potentially make a PR) #699

Closed
opened 2026-01-29 22:16:06 +00:00 by claunia · 1 comment
Owner

Originally created by @mitchcapper on GitHub (Sep 11, 2025).

I noticed zstd is not supported for tar but this library does include the zstd c# library for a select few other functions.

I was able to work around this fairly easily by just creating the zstd stream myself to pass to the reader factory, but I am not sure if there is a reason not to do something similar in the official code. Given the ability to rewind the sharpcompress stream wrapper and the fact IReader is meant as forward only it would seem like this should work but I don't know the internals of sharpcompress well enough to say if I am missing something. If not happy to do a PR to add zstd as a tar supported format.

Here is my current code:

var entries = new SortedSet<ArchiveEntry>();
Stream stream = File.OpenRead(archivePath);
toDispose.Add(stream);
if (archivePath.EndsWith("tar.zstd", StringComparison.CurrentCultureIgnoreCase) || archivePath.EndsWith("tar.zst") || archivePath.EndsWith(".tzst")|| archivePath.EndsWith(".tzstd")) {
				stream = new ZstdSharp.DecompressionStream(stream);
				toDispose.Add(stream);
}

if (reader == null)
				reader = ReaderFactory.Open(stream);
Originally created by @mitchcapper on GitHub (Sep 11, 2025). I noticed zstd is not supported for tar but this library does include the zstd c# library for a select few other functions. I was able to work around this fairly easily by just creating the zstd stream myself to pass to the reader factory, but I am not sure if there is a reason not to do something similar in the official code. Given the ability to rewind the sharpcompress stream wrapper and the fact IReader is meant as forward only it would seem like this should work but I don't know the internals of sharpcompress well enough to say if I am missing something. If not happy to do a PR to add zstd as a tar supported format. Here is my current code: ```csharp var entries = new SortedSet<ArchiveEntry>(); Stream stream = File.OpenRead(archivePath); toDispose.Add(stream); if (archivePath.EndsWith("tar.zstd", StringComparison.CurrentCultureIgnoreCase) || archivePath.EndsWith("tar.zst") || archivePath.EndsWith(".tzst")|| archivePath.EndsWith(".tzstd")) { stream = new ZstdSharp.DecompressionStream(stream); toDispose.Add(stream); } if (reader == null) reader = ReaderFactory.Open(stream); ```
claunia added the enhancementup for grabs labels 2026-01-29 22:16:06 +00:00
Author
Owner

@adamhathcock commented on GitHub (Sep 15, 2025):

Please do a PR with a test or two. Thanks!

@adamhathcock commented on GitHub (Sep 15, 2025): Please do a PR with a test or two. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#699