Skip to content

picrap/LzmaStream

Repository files navigation

LzmaStream

Trying to get LZMA mainstream 😜

Available as a NuGet package package.

What is it?

A Stream that works exactly as you would expect: read from it and unpack or write to it and pack (the same way you would do with GZipStream)

How to use it

To decompress data:

// packedStream is the LZMA packed source stream
using (var lzmaStream = new LzmaStream(packedStream, CompressionMode.Decompress))
{
    lzmaStream.CopyTo(unpackTarget);
    // or
    // lzmaStream.Read(unpackData, 0, unpackData.Length);
}

… And to compress it:

// packedStream is a stream receiving packed data
using (var lzmaStream = new LzmaStream(packedStream, CompressionMode.Compress))
// or
// using (var lzmaStream = new LzmaStream(rawStream, LzmaCompressionParameters.Defaut /* or .Optimal or .Fast or custom… */))
{
    // copy from an unpacked stream to LZMA output
    rawStream.CopyTo(lzmaStream);
    // or
    // lzmaStream.Write(rawData, 0, rawData.Length);
}

Credits

This library uses unmodified source code from https://www.7-zip.org/sdk.html (from another repository)

About

Trying to get LZMA mainstream

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages