TapeArchive 3.0.1

dotnet add package TapeArchive --version 3.0.1                
NuGet\Install-Package TapeArchive -Version 3.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TapeArchive" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TapeArchive --version 3.0.1                
#r "nuget: TapeArchive, 3.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TapeArchive as a Cake Addin
#addin nuget:?package=TapeArchive&version=3.0.1

// Install TapeArchive as a Cake Tool
#tool nuget:?package=TapeArchive&version=3.0.1                

TapeArchive

Nuget

Usage

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:

  1. Original TAR that shipped with AT&T UNIX Version 7
  2. Pre-POSIX (AKA. POSIX.1-1988 draft)
  3. POSIX.1-1988 (AKA. ustar)
  4. pax (AKA. POSIX.1-2001)
  5. GNU
  6. Solaris
  7. AIX
  8. 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.

Reading

using TapeArchive;

await using var reader = new TapeArchive(stream, true);

await foreach (var item in reader.ReadAsync())
{
    // Do something with item.
}

Writing

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();

Breaking changes

2.0 to 3.0

IArchiveBuilder.WriteItemAsync has been added a parameter to specify how to create parent entries.

1.0 to 2.0

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.

Development

Prerequisites

  • Latest .NET SDK

Build

dotnet build src/TapeArchive.sln

Run tests

dotnet test src/TapeArchive.sln

License

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TapeArchive:

Package Downloads
CreativeCoders.IO

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 2,160 5/18/2022
3.0.0 433 5/17/2022
2.0.0 451 4/27/2022
1.1.0 458 4/5/2022
1.0.0 441 4/3/2022