GZip.jl — A Julia interface for gzip functions in zlib¶
This module provides a wrapper for the gzip related functions of (zlib), a free, general-purpose, legally unencumbered, lossless data-compression library. These functions allow the reading and writing of gzip files.
Notes¶
- This interface is only for gzipped files, not the streaming zlib compression interface. Internally, it depends on/uses the streaming interface, but the gzip related functions are higher level functions pertaining to gzip files only.
GZipStreamis an implementation ofIOand can be used virtually anywhereIOis used.- This implementation mimics the
IOStreamimplementation, and should be a drop-in replacement forIOStream, with some caveats:
seekend()andtruncate()are not availablereaduntil()is available, but is not very efficient. (Butreadline()works fine.)
In addition to open(), gzopen() and gzdopen(), the
following IO/IOStream functions are supported:
close()flush()seek()skip()position()eof()read()readuntil()readline()write()peek()
Due to limitations in zlib, seekend() and truncate() are not available.
Functions¶
-
GZip.open(fname[, gzmode[, buf_size]])¶ Alias for
gzopen(). This is not exported, and must be called usingGZip.open().
-
GZip.gzopen(fname[, gzmode[, buf_size]])¶ Opens a file with mode (default
"r"), setting internal buffer size to buf_size (defaultZ_DEFAULT_BUFSIZE=8192), and returns a the file as aGZipStream.gzmodemust contain one ofr read w write, create, truncate a write, create, append In addition, gzmode may also contain
x create the file exclusively (fails if file exists) 0-9 compression level and/or a compression strategy:
f filtered data h Huffman-only compression R run-length encoding F fixed code compression Note that
+is not allowed in gzmode.If an error occurs,
gzopenthrows aGZError
-
GZip.gzdopen(fd[, gzmode[, buf_size]])¶ Create a
GZipStreamobject from an integer file descriptor. Seegzopen()forgzmodeandbuf_sizedescriptions.
-
GZip.gzdopen(s[, gzmode[, buf_size]]) Create a
GZipStreamobject fromIOStreams.
Types¶
-
type
GZip.GZipStream(name, gz_file[, buf_size[, fd[, s]]])¶ Subtype of
IOwhich wraps a gzip stream. Returned bygzopen()andgzdopen().
-
type
GZip.GZError(err, err_str)¶ gzip error number and string. Possible error values:
Z_OKNo error Z_ERRNOFilesystem error (consult errno())Z_STREAM_ERRORInconsistent stream state Z_DATA_ERRORCompressed data error Z_MEM_ERROROut of memory Z_BUF_ERRORInput buffer full/output buffer empty Z_VERSION_ERRORzlib library version is incompatible with caller version