NOTE: If you are starting a new project on Julia 0.6 or later, it is recommended to use the CodecZlib.jl package instead. CodecZlib.jl and other packages offer more unified interfaces for a wide range of file formats.
This is yet another zlib interface for Julia. It's intended to replace the two prior zlib packages.
Both have shortcomings that this package aims to address, specifically:
This library exports four stream types:
||write and decompress data|
||write and compress data|
||read and decompress data|
||read and compress data|
These work like regular
IO objects. Each takes as a parameter either in input
or output source.
# read lines from a compressed file for line in eachline(open("data.txt.gz") |> ZlibInflateInputStream) # do something... end # write compressed data to a file io = open("data.txt.gz", "w") stream = ZlibDeflateOutputStream(io) for c in rand(UInt8, 10000) write(stream, c) end close(stream) # this closes not only `stream` but also `io` # pointlessly compress and decompress some data (use `read` on v0.5) readbytes(rand(UInt8, 10000) |> ZlibDeflateInputStream |> ZlibInflateInputStream)
There are convenience
functions that take a byte array and return another compressed or decompressed
Checksum functions are exposed as
See BufferedStreams.jl for benchmarks of this library.
Low-level APIs are defined in src/lowlevel.jl. These constants and functions are not exported but available if necessary. At the moment, function wrappers are minimal but feel free to add and send functions you need as pull requests.
9 months ago