All Projects → zerkman → zzlib

zerkman / zzlib

Licence: WTFPL license
zlib-compressed file depacking library in Lua

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to zzlib

Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (+100%)
Mutual labels:  gzip, zip, zlib
Turbobench
Compression Benchmark
Stars: ✭ 211 (+379.55%)
Mutual labels:  gzip, zip, zlib
Swcompression
A Swift framework for working with compression, archives and containers.
Stars: ✭ 110 (+150%)
Mutual labels:  gzip, zip, zlib
Datacompression
Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Stars: ✭ 191 (+334.09%)
Mutual labels:  gzip, zip, zlib
ratarmount
Random Access Read-Only Tar Mount
Stars: ✭ 217 (+393.18%)
Mutual labels:  gzip, zip, extract
compress
compress and uncompress for Deno
Stars: ✭ 29 (-34.09%)
Mutual labels:  gzip, zip, deflate
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (+229.55%)
Mutual labels:  gzip, zip, extract
power-gzip
POWER9 gzip engine documentation and code samples
Stars: ✭ 16 (-63.64%)
Mutual labels:  gzip, zlib, deflate
deflate-rs
An implementation of a DEFLATE encoder in rust
Stars: ✭ 47 (+6.82%)
Mutual labels:  gzip, zlib, deflate
python-isal
Faster zlib and gzip compatible compression and decompression by providing python bindings for the isa-l library.
Stars: ✭ 21 (-52.27%)
Mutual labels:  gzip, zlib, deflate
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+7565.91%)
Mutual labels:  gzip, zip, extract
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+3075%)
Mutual labels:  gzip, zip
Libflate
A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP)
Stars: ✭ 125 (+184.09%)
Mutual labels:  gzip, zlib
Bit7z
A C++ static library offering a clean and simple interface to the 7-zip DLLs.
Stars: ✭ 159 (+261.36%)
Mutual labels:  gzip, zip
Iostreams
IOStreams is an incredibly powerful streaming library that makes changes to file formats, compression, encryption, or storage mechanism transparent to the application.
Stars: ✭ 84 (+90.91%)
Mutual labels:  gzip, zip
Denoflate
WebAssembly powered Deflate/Gzip/Zlib compression for Deno, written in Rust
Stars: ✭ 80 (+81.82%)
Mutual labels:  gzip, zlib
Uzlib
Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).
Stars: ✭ 168 (+281.82%)
Mutual labels:  gzip, zlib
ZeeArchiver
Zee is an efficient and simple to use Android Archiver and decompressor. It can decompress and compress from-to all the formats supported by the well known 7zip utility. Copyright © 2018 Mahmoud Galal , for support contact me:[email protected]
Stars: ✭ 35 (-20.45%)
Mutual labels:  zip, extract
em inflate
Fast, small, in-memory inflate (zlib, deflate and gzip decompression)
Stars: ✭ 59 (+34.09%)
Mutual labels:  gzip, zlib
Unifiedarchive
UnifiedArchive - an archive manager with a unified way for different formats. Supports all basic (listing, reading, extracting and creation) and specific features (compression level, password-protection). Bundled with console program for working with archives.
Stars: ✭ 246 (+459.09%)
Mutual labels:  gzip, zip

zzlib

This is a pure Lua implementation of a depacker for the zlib DEFLATE(RFC1951)/GZIP(RFC1952) file format. zzlib also allows the decoding of zlib-compressed data (RFC1950). Also featured is basic support for extracting files from DEFLATE-compressed ZIP archives (no support for encryption).

The implementation is pretty fast. It makes use of the built-in bit32 (PUC-Rio Lua) or bit (LuaJIT) libraries for bitwise operations. Typical run times to depack lua-5.3.3.tar.gz on a single Core i7-6600U are 0.87s with Lua ≤ 5.2, 0.50s with Lua 5.3, and 0.17s with LuaJIT 2.1.0.

zzlib is distributed under the WTFPL licence. See the COPYING file or http://www.wtfpl.net/ for more details.

Usage

There are various ways of using the library.

Stream from a GZIP file

-- import the zzlib library
zzlib = require("zzlib")

-- get the unpacked contents of the file in the 'output' string
local output,err = zzlib.gunzipf("input.gz")
if not output then error(err) end

Read GZIP/zlib data from a string

Read a file into a string, call the depacker, and get a string with the unpacked file contents, as follows:

-- import the zzlib library
zzlib = require("zzlib")
...

if use_gzip then
  -- unpack the gzip input data to the 'output' string
  output = zzlib.gunzip(input)
else
  -- unpack the zlib input data to the 'output' string
  output = zzlib.inflate(input)
end

Extract a file from a ZIP archive stored in a string

Read a file into a string, call the depacker, and get a string with the unpacked contents of the chosen file, as follows:

-- import the zzlib library
zzlib = require("zzlib")
...

-- extract a specific file from the input zip file
output = zzlib.unzip(input,"lua-5.3.4/README")

Process the list of files from a ZIP archive stored in a string

The zzlib.files() iterator function allows you to span the whole list of files in a ZIP archive, as follows:

for _,name,offset,size,packed,crc in zzlib.files(input) do
  print(string.format("%10d",size),name)
end

During such a loop, the packed boolean variable is set to true if the current file is packed. You may then decide to unpack it using this function call:

output = zzlib.unzip(input,offset,crc)

If the file is not packed, then you can directly extract its contents using string.sub:

output = input:sub(offset,offset+size-1)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].