Before using this library you need to understand some basic of TAR structure. DO NOT SKIP THIS otherwise you won't known how to properly working with this library.
TAR is acronym for Tape Archive. It was designed for writing and reading to/from a tape drive. That mean its structure was designed for sequential access, not random access. If you want to seek to a specific file in a TAR what most library actually do is keep reading and discard all data until it reach that file. And TAR does not support compression by itself. The compression you see like file.tar.gz is just a TAR that compressed witgh GZIP later.
TAR format have a lot of variants:
- Original TAR that shipped with AT&T UNIX Version 7
- Pre-POSIX (AKA. POSIX.1-1988 draft)
- POSIX.1-1988 (AKA. ustar)
- pax (AKA. POSIX.1-2001)
- GNU
- Solaris
- AIX
- macOS
Usually most reader will be able to extract any variants. This library currently support up to ustar. But just as I said before that most reader will be able to extract any variants, including this library. So you should not have any problem when reading. For writing try to stick with ustar due to some reader like GNU Tar does not handle file mode properly for origial variant.
using TapeArchive;
await using var reader = new TapeArchive(stream, true);
await foreach (var item in reader.ReadAsync())
{
// Do something with item.
}
using System;
using TapeArchive;
await using var builder = new ArchiveBuilder(stream, true);
var item = new UstarItem(PrePosixType.RegularFile, new("./file1"))
{
Content = content,
Size = size,
};
await builder.WriteItemAsync(item, null);
await builder.CompleteAsync();
IArchiveBuilder.WriteItemAsync
has been added a parameter to specify how to create parent entries.
Disposing of IArchiveBuilder
is changed. In 1.0 it will complete the archive. For 2.0 it will abort the archive if archive is not completed with
CompleteAsync
. The aborted archive is a broken TAR and cannot be read by any TAR readers.
- Latest .NET SDK
dotnet build src/TapeArchive.sln
dotnet test src/TapeArchive.sln
MIT