MCSuperServer

GzipFile

ParDoor

SR

ICR

GzipFile

Description

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.

Classes

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.

Included Files

GzipFile.h Interface for the CGzipFile class and others
GzipFile.cpp Definition of the CGzipFile class and others
zlib.h Interface of the zlib general purpose compression library
zconf.h Configuration of the zlib compression library
zlib.lib The zlib library compiled as a Win32 static library
Zlib113.zip Full source code for zlib library
scribble.exe An example application. All files saved by this program are gzip compressed but it can load either compressed or uncompressed. Requires "mfc42.dll"
gzipfile.SCB An example gzip compressed scribble document.
minigzip.exe 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.exe

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" to decompress.
"gzip gzipfile.scb" & "ren gzipfile.scb.gz gzipfile.scb" to compress.

Gzip.txt

the GNU GENERAL PUBLIC LICENSE

File_id.diz Short description for zip file.
gzipfile.html This file.

How To Use

  1. Put "zlib.h", "zconf.h", "zlib.lib", "gzipfile.h", "gzipfile.cpp" in the project source directory
  2. Add "zlib.lib" and "gzipfile.cpp" to project
  3. Add "#include <zlib.h>" and "#include <gzipfile.h>" to "stdafx.h"

Then Either

  1. Add "DECLARE_GZIPARCHIVE()" to the bottom of your document class declaration
  2. Add "IMPLEMENT_GZIPARCHIVE(CMyDocument)" with your document class definition where "CMyDocument" is your document class name

Or

  1. 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

About zlib

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.

  1. Unzip all files into a temporary directory
  2. 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.
  3. Copy the unzipped files to the project directory. You only need the ".c" and ".h" files.
  4. Add to project, all ".c" files except "example.c", "minigzip.c" and "maketree.c"
  5. Set the required run-time library. I recommend setting Use run-time library: Multithreaded DLL because MFC uses it.
  6. Set the code optimizations. I recommend setting Optimizations: Maximize Speed and using Inline function expansion: Any Suitable.
  7. Optionally set Not using precompiled headers to build faster.
  8. 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

Summary

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)
MFC Versions 4.0, 4.2, 4.21, 6.0 and future versions
Source Code Full source code is included
Architectures Tested 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.

Support

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.

Disclaimer

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 owns them.

Download (360KB)

Your name
Your email address
Send me email about updates

   

This information is for internal use only.

Contacting the Author

Paul Andreassen
Email: paul @ andreassen com au
Web: http://wwww.andreassen.com.au or http://members.iinet.net.au/~paulone/gzipfile.html

Copyright 2012 Paul Andreassen