ZarSharp 0.1.0

dotnet add package ZarSharp --version 0.1.0
                    
NuGet\Install-Package ZarSharp -Version 0.1.0
                    
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="ZarSharp" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZarSharp" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ZarSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZarSharp --version 0.1.0
                    
#r "nuget: ZarSharp, 0.1.0"
                    
#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.
#:package ZarSharp@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZarSharp&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ZarSharp&version=0.1.0
                    
Install as a Cake Tool

ZarSharp

ZarSharp is a pure-managed, idiomatic .NET 8 implementation of the ZArchive v1 archive format (.zar and .wua). It reads and creates archives without binding to the upstream C++ library or shipping native binaries. Zstandard compression is provided by the pure-C# ZstdSharp.Port package.

Features

  • Random-access, seekable reads from independently compressed 64 KiB blocks.
  • Append-only archive creation that works with non-seekable and write-once streams.
  • Synchronous and cancellation-aware asynchronous APIs.
  • Thread-safe concurrent reads with a bounded decompressed-block LRU cache.
  • Strict structural validation and explicit whole-archive SHA-256 verification.
  • Platform-independent Windows-1252 paths with the format's ASCII-only case folding.
  • Compatibility tests in both directions with Exzap's v0.1.2 reference tool.

Install

dotnet add package ZarSharp

Create an archive

using ZarSharp;

await using var output = File.Create("content.zar");
await using var writer = ZArchiveWriter.Create(output);

writer.CreateDirectory("empty-folder");
await using var source = File.OpenRead("picture.bin");
await writer.WriteEntryAsync("assets/picture.bin", source);
await writer.CompleteAsync();

The output only needs to be writable; it does not need to support seeking. Parent directories are created automatically. Only one stream returned by CreateEntry may be open at a time.

Read an archive

using ZarSharp;

await using var archive = await ZArchiveReader.OpenAsync("content.zar");
var entry = archive.GetEntry("ASSETS/picture.bin")
    ?? throw new FileNotFoundException();

await using var input = entry.Open();
input.Seek(64 * 1024, SeekOrigin.Begin);
var buffer = new byte[4096];
var bytesRead = await input.ReadAsync(buffer);

if (!await archive.VerifyIntegrityAsync())
    throw new InvalidDataException("The archive checksum does not match.");

Opening validates the footer, section ranges, block table, name table, and complete file tree. VerifyIntegrity is explicit because it must read the entire archive and can be expensive for multi-terabyte files.

Paths and interoperability

Writers accept relative paths using / or \ and serialize them with / semantics. Names must round-trip through Windows-1252. Absolute paths, empty components, . and .., embedded NUL characters, unrepresentable Unicode, components longer than 32,767 encoded bytes, and ASCII-case-insensitive sibling duplicates are rejected.

The reader accepts both separators and compares only ASCII letters without regard to case, matching the reference implementation. Non-ASCII letters remain case-sensitive.

ZArchive does not support editing an archive after creation. The metadata sections in format version 1 have no defined upstream semantics, so ZarSharp validates their ranges but otherwise ignores them.

Stream ownership and thread safety

File-path overloads own their file streams. Stream overloads dispose the supplied stream by default; pass leaveOpen: true to retain ownership. A reader supports concurrent reads from separate entry streams. Individual entry streams and writers are not thread-safe.

License

ZarSharp is licensed under MIT-0. See THIRD-PARTY-NOTICES.md for the managed Zstandard dependency and format-reference notices.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 99 7/21/2026