Gzipfile compresses MFC serialized document data. The only code changes required
are a few include statements and macro instantiations in a CDocument derived
class. Uncompressed documents can still be loaded and all saved documents are
compressed. The compression engine is mature, widely used and extremely fast.
CGzipFile is derived from CFile and it reads and writes compressed files that
are gzip (.gz) compatible. CGzipFile can be interchanged with CFile and CStdioFile.
The class CGzipMirrorFile is derived from CGzipFile and is a robust gzip file
save based on the MFC CMirrrorFile. Its main purpose is, if the file exists,
will be overwritten and there is enough free space, to open a temporary file.
If the save is completed successfully, the original file is deleted and the
temporary file renamed.
CGzipDocument is derived from CDocument and is it replacement with gzip support.
This can be used if preferred over the use of the macros.
||Interface for the CGzipFile class and others
||Definition of the CGzipFile class and others
||Interface of the zlib general purpose compression library
||Configuration of the zlib compression library
||The zlib library compiled as a Win32 static library
||Full source code for zlib library
||An example application. All files saved by this program are gzip compressed
but it can load either compressed or uncompressed. Requires "mfc42.dll"
||An example gzip compressed scribble document.
||This is a console program that will accept piped input or a file name.
Use -d for decompression.
"minigzip -d < hello.scb > hellod.scb" to decompress.
"minigzip < hellod.scb > helloc.scb" to compress.
gzip 1.2.4 (18 Aug 93) (included under the GNU GENERAL PUBLIC LICENSE)
"gzip -l gzipfile.scb" to display compressed size, uncompressed
size and compression ratio.
"ren gzipfile.scb gzipfile.scb.gz" & "gzip -d gzipfile.scb.gz"
"gzip gzipfile.scb" & "ren gzipfile.scb.gz gzipfile.scb"
the GNU GENERAL PUBLIC LICENSE
||Short description for zip file.
How To Use
- Put "zlib.h", "zconf.h", "zlib.lib", "gzipfile.h",
"gzipfile.cpp" in the project source directory
- Add "zlib.lib" and "gzipfile.cpp" to project
- Add "#include <zlib.h>" and "#include <gzipfile.h>"
- Add "DECLARE_GZIPARCHIVE()" to the bottom of your document class
- Add "IMPLEMENT_GZIPARCHIVE(CMyDocument)" with your document class
definition where "CMyDocument" is your document class name
- Change your documents base class to "CGzipDocument" e.g.. Search
and Replace "CDocument" to "CGzipDocument"
If you receive an link warning like the following, it means that your project
and "zlib.lib" are using different run-time libraries. The most common
cause is compiling your project with the Debug configuration, while the "zlib.lib"
is precompilied for the Release configuration. This is explained further in
the next section.
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other
libs; use /NODEFAULTLIB:library
These classes use the zlib library, a general purpose compression library.
The "zlib.lib" file is compiled with Visual C++ 6.0 service pack
2 using the Multithreaded DLL run-time library and may give link errors if used
with another type of run-time library. If you use another compiler or require
a different run-time library please recompile as described below.
- Unzip all files into a temporary directory
- Create a new non MFC static library project. In Visual C++ it is called
Win32 Static Library. In Visual C++ you are asked if you require Pre-Compiled
header or MFC support, leave these unselected.
- Copy the unzipped files to the project directory. You only need the ".c"
and ".h" files.
- Add to project, all ".c" files except "example.c", "minigzip.c"
- Set the required run-time library. I recommend setting Use run-time library:
Multithreaded DLL because MFC uses it.
- Set the code optimizations. I recommend setting Optimizations: Maximize
Speed and using Inline function expansion: Any Suitable.
- Optionally set Not using precompiled headers to build faster.
- Then build. If you create a debug version, you can set breakpoints and use
other debug functions on this code.
Authors of zlib
Jean-loup Gailly and Mark Adler
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
More information on zlib see zlib113.txt
|Current Tool kit Version
||Released 4nd September 1999
|Original Tool kit Version
||Released 1st December 1997
|Supported Visual C++ Versions, 32-bit
||4.0, 4.2, 5.0, 6.0 and future versions
|Supported Visual C++ Versions, 16-bit
||Untested (should work)
||4.0, 4.2, 4.21, 6.0 and future versions
||Full source code is included
||Intel only (others should work)
Changes in Current Version
- Uses latest version of zlib 1.1.3
- Written for MFC 6.0
- CGzipFile can now be interchanged with CStdioFile and well as CFile.
- Supports reading and writing of strings.
- Has a limited seek function.
Any suggestion or improvement can be sent to paul @ andreassen com au
with "GzipFile" as the subject.
If you encounter bugs in this software, please give a good description and a
fix if available.
I have nothing to do with zlib library maintenance and as such is
not interested in such bugs.
Copyright 1997-2003 Paul Andreassen
THE SOFTWARE IS PROVIDED "AS-IS'' AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
OR FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL PAUL ANDREASSEN BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT
OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE,
AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.
All the registered trademarks used herein are registered to whoever it is that
This information is for internal use only.
Contacting the Author
Email: paul @ andreassen com au
Web: http://wwww.andreassen.com.au or
Copyright 2012 Paul Andreassen