| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Pure-C# port of the ZArchive 0.1.2 library — directory-tree archives with per-block zstd compression. Zero native dependencies, BCL only; trimmable and AOT-compatible (net8.0 / net9.0 / net10.0).
dotnet add package ZArchiveSharpusing ZArchiveSharp;
// Pack a directory (each 64 KiB block zstd level 6 by default)
ZArchiveTool.Pack(@"C:\game", @"C:\game.zar");
// Extract it back
ZArchiveTool.Extract(@"C:\game.zar", @"C:\game_out");using ZArchiveSharp;
using ZArchiveSharp.Zstd;
// Write an archive
using var output = File.Create("game.zar");
using var writer = new ZArchiveWriter(output); // default: ZstdCompressor level 6
writer.StartNewFile("readme.txt");
writer.AppendData("hello"u8);
writer.Finalize();
// Read it back
using var reader = ZArchiveReader.TryOpen("game.zar");using ZArchiveSharp;
using var reader = ZArchiveReader.TryOpen("game.zar",
new ZArchiveReaderOptions { FileShare = FileShare.ReadWrite },
out var failure);
if (reader == null)
{
Console.WriteLine($"Invalid archive: {failure}");
return;
}
// Enumerate with node handles (no path rebuilds); stream any file.
for (uint i = 0; i < reader.GetDirEntryCount(ZArchiveReader.RootNode); i++)
{
if (reader.TryGetDirEntry(ZArchiveReader.RootNode, i, out var node, out var entry) && entry.IsFile)
{
using var stream = reader.OpenRead(node);
// stream.CopyTo(destination);
}
}TryGetNodeName returns the stored (canonical) name for a handle, and EntryCount / TotalUncompressedSize report archive stats computed at open. Open failures are specific: ZArchiveOpenFailure distinguishes BadMagic, UnsupportedVersion, LengthMismatch, SectionOutOfRange, FileNotFound, InvalidPath, and the other validation and I/O reasons. Distinct 64 KiB blocks decompress in parallel; CacheBlockCount tunes the shared LRU cache.
using ZArchiveSharp.Zstd;
// Compress (byte-identical to libzstd)
var compressor = new ZstdCompressor(ZstdCompressionOptions.FromLevel(6));
byte[] frame = compressor.CompressBlock(data); // single-shot, any size
// Decompress
byte[] back = ZstdCompressor.DecompressFrame(frame, maxSize: data.Length);using ZArchiveSharp.Zstd;
// Stream a file through zstd (any chunk size; flushed, never closed)
using var input = File.OpenRead("big.bin");
using var output = File.Create("big.zst");
using var enc = new ZstdCompressionStream(output, level: 6);
input.CopyTo(enc);
// Compress small entries with a dictionary (4× smaller here)
var dict = ZstdDictionary.FromRawPrefix(prefixBytes);
var opts = new ZstdCompressionOptions { Level = 6, Dictionary = dict };
byte[] small = new ZstdCompressor(opts).CompressBlock(entry);
byte[] orig = ZstdDecompressor.Decompress(small, dict);| Subsystem | Key types | One line |
|---|---|---|
| Container | ZArchiveWriter, ZArchiveReader, ZArchiveTool | Directory-tree .zar archives; Pack/Extract one-liners |
| zstd codec | ZstdCompressor, ZstdDecompressor, ZstdCompressionOptions, ZstdDecoderOptions | Levels 1–22, byte-identical to libzstd 1.5.7 |
| Streams & dicts | ZstdCompressionStream, ZstdDecompressionStream, ZstdDictionary | Stream wrappers; formatted + raw-prefix dictionary use |
| Seekable | SeekableWriter, SeekableReader, SeekTable, SeekableOptions | Foot + Head seek tables, subrange decode |
| Pipeline | ZarPipeline, ZarPackEngine, ZarPipelineOptions, ZarBatchRequest, ProcessRunner, SevenZip | Parallel batches, 7z container stage, collision policies |
| CLI runners | ZarchiveCli, ZstdCli, SeekableCli | Callable forms of every zar command (same exit codes) |
Full signatures: API Reference.
# Install as a global tool
dotnet tool install -g ZArchiveSharp.Cli
# Pack a directory
zar <directory> [output.zar]
# Extract an archive
zar <archive.zar> [output_dir]
# Convert XISO to .zar (Redump ISOs auto-detected: packs the game partition)
zar --iso <game.iso> [output.zar]
# Raw zstd files (stdin/stdout by default, pipes compose)
zar zstd --compress big.bin big.zst
zar zstd --decompress big.zst big.bin
zar zstd -c big.bin | zar zstd -d > big.bin
# Archives with dictionaries + checksums
zar --dict words.dict --check <directory> [output.zar]
# Seekable zstd files (zeekstd-compatible framing + slicing)
zar seekable compress big.bin big.zst
zar seekable list big.zst
zar seekable decompress --from 1M --to 2M big.zst slice.bin
# Batch: archives through 7z to ISO/dir to .zar, ISOs straight to .zar
zar --batch C:\games C:\archives
zar --batch --mode extract-archive C:\games C:\unpacked
zar --batch --seven-zip "D:\tools\7z.exe" C:\games C:\archives
# Paths that begin with '-' via the option terminator
zar -- -odd-directory out.zarThe CLI also ships as framework-dependent standalone bundles (per platform and architecture): the executable is ZArchiveSharp (ZArchiveSharp.exe on Windows), so replace zar with ZArchiveSharp in the examples above. Help and usage text always print the name it was launched as.
The CLI sends opt-out telemetry (anonymous usage stats, a background update check, and bug reports for warnings/errors). Disable it with --no-telemetry or ZAR_BUG_REPORT=off; --help/--version never send anything.
| Project | Description |
|---|---|
| ZArchiveSharp | Core library — archive reader/writer, zstd codec, seekable format, pipeline |
| ZArchiveSharp.Cli | Command-line tool (zar) — pack, extract, convert, batch operations |
| ZArchiveSharp.Benchmarks | BenchmarkDotNet performance suite |
| ZArchiveSharp.Tests | Comprehensive test suite (4291 tests + 43 CLI battle tests, parity validation) |
The encoder, archive container and seekable framing are byte-identical to the frozen references (libzstd 1.5.7, zeekstd). The test suite proves it against native tools on thousands of vectors, and ZArchiveSharp.Tests/Goldens/ pins native bytes so CI holds the line with no toolchain installed.
Two known boundaries:
Non-commercial — see LICENSE. ZArchiveSharp is a derivative work of ZarManager 1.2.0 and incorporates permissively licensed components (ZArchive, libzstd, zeekstd, seekable-zstd, benchmark baselines); their notices are listed in THIRD-PARTY-NOTICES.md. Commercial use, selling, and use in commercial applications or products are prohibited without prior written consent from the copyright holders. The v1.2.0 packages were published under MIT; releases after v1.2.0 use this license.
Contributions are welcome (accepted under the non-commercial project license)! Please see the issue tracker for known issues and feature requests.
| Back | FazBrowse Home | New Git URL |