A fast and efficient forward-only reader for `Tar` archives.
$ dotnet add package Community.Archives.TarA fast and efficient forward-only reader for Tar archives.
Task to offload IO to separate threads.This package is part of Gitii/Community.Archives: A collection of libraries that support reading various popular archives.
On any platform that's supported by the above frameworks, including Windows, Linux and MacOS.
TarArchiveReader is implemented based on GNU tar 1.34: Basic Tar Format and tar (computing) - Wikipedia.
Only POSIX format is supported
Tar files do not have metadata. GetMetaDataAsync will throw an exception at runtime.
Compressed Tar archives are supported: gzip, bzip, xz and lz are detected and decompressed on the fly.
var reader = new TarArchiveReader();
await foreach (
var entry in reader
.GetFileEntriesAsync(stream, IArchiveReader.MATCH_ALL_FILES)
) {
// entry.Name
// entry.Content
Console.WriteLine($"Found file {entry.Name} ({entry.Content.Length} bytes)")
}
var reader = new TarArchiveReader();
// use regular expression to match files (path + file name)
await foreach (
var entry in reader
.GetFileEntriesAsync(stream, "[.]md$", "[.]txt$")
) {
// found a Markdown or text file
}