Gzstream Library Home Page
Gzstream is a small C++ library, basically just a wrapper,
that provides the functionality of the
zlib C-library in a C++ iostream.
It is freely available under the LGPL license.
Gzstream has been written by
Deepak Bandyopadhyay and
Lutz Kettner at
Geometry Group at UNC Chapel Hill.
Gzstream requires a standard compliant C++ compiler (we use the new
header file conventions and the new iostream in the std:: name space)
and, of course, zlib. We used zlib 1.1.3 so far, but see the zlib home page for why you should
upgrade to zlib 1.1.4. So, in theory, the provided sources could run
on many platforms. However, we used only the following few
- PC Linux, RedHat 6.1, g++ version 2.95.2
- PC Linux, Debian, g++ version 2.95.2 and 3.1
- SGI Irix 6.5, MIPSpro CC version 7.30
Either compile gzstream.C by hand, place it in some library,
and move gzstream.h into the include search path of your
compiler. Or use the provided Makefile, adapt its
variables, and follow the remarks in the Makefile. Two
test programs are provided, test_gzip.C and test_gunzip.C.
The Makefile contains a rule that performs a small test
with these programs.
The library provides two classes, igzstream and ogzstream,
that can be used analogously to ifstream and ofstream
The classes are by default in the global name space. This can
be changed by setting the macro GZSTREAM_NAMESPACE to
the desired name space, e.g., by setting the option
-DGZSTREAM_NAMESPACE=gz in the Makefile.
However, this needs to be consistent for both, the library compilation
and the application that uses the library.
- Seek. The zlib library provides the necessary functionality,
but we have not realized that in the wrapper (yet? ;-).
- Both streams are based on the same streambuffer. So, they
cannot be used to derive an iogzstream class that would allow
simultaneous reading and writing to the same file.
Download and Release Notes
- Gzstream library 1.5 (08 Apr 2003):
Fixed bug that did not set the state correctly on failure to open or
close a file.
Fixed bug in the indexing of the write buffer that
caused the write buffer to shrink continously and finally caused
wrong results when writing compressed files (only observed on some
- Gzstream library 1.4 (27 Apr 2002):
Fixed a bug that stopped stream output after calling flush()
or using std::endl.
- Gzstream library 1.3 (06 Nov 2001):
Fixed unsigned char -- signed char bug. Increased buffer size
for better performance.
- Gzstream library 1.2 (04 Oct 2001):
Initial release as gzstream, renamed from zipstream.
- Zipstream library 1.1 (09 Sep 2001):
Credits for finding bugs and improving this software go to:
Vincent Ricard, Peter Milley, Peter J. Torelli, and Ares Lagae.
The Computational Geometry Group at UNC Chapel Hill, Jan. 08, 2003.