For Programmers: Free Programming Magazines  


Home > Archive > Compression > March 2007 > creating zip files from zlib.dll









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author creating zip files from zlib.dll
Jens Müller

2007-03-21, 6:55 pm

Hello,

I use the zlib.dll to store compressed internal data. It works very
well.
Now I want to provide the users with the possibility to dave this data
compressed as it is as Zip file, with the ability to decompress it.

As far as I know, zlib.dll uses the deflate algorithm.

To be able to save the data readable by zip programs, I have to embed
the inflated bytes into the zip format. Will it work like that?

Here I need a bit help:
I got the zip specification
local file header signature 4 bytes (0x04034b50)
...
last mod file time 2 bytes
How to calculate this? Time of the creation or modification
of the file? Mod by what?
last mod file date 2 bytes
Same here.
...
file name length 2 bytes
extra field length 2 bytes
I suppose I need no extra field?

After this, the filename would come and then the data from the
zlib.dll.
Now I'm a bit what comes next with the "Central directory
structure". I do not need any directory structure, the only file has to
be directly in the zip. Would you need all the headers here again?
And what comes after it?

Thanks a lot!
Jens


Mark Adler

2007-03-21, 6:55 pm

On Mar 21, 11:36 am, Jens M=FCller <m...@privacy.net> wrote:
> I got the zip specification


Then that should answer your questions, if carefully read. Just to
make sure you have the right one:

http://www.pkware.com/documents/casestudies/APPNOTE.TXT

Yes, you need a central directory if you want a valid zip file that
other programs can read.

Mark

mueller.jens@gmail.com

2007-03-22, 9:55 pm

> Then that should answer your questions, if carefully read. Just to
> make sure you have the right one:
>
> http://www.pkware.com/documents/casestudies/APPNOTE.TXT


Thanks.
date and time fields: (2 bytes each)

The date and time are encoded in standard MS-DOS format.
If input came from standard input, the date and time are
those at which compression was started for this data.
If encrypting the central directory and general purpose bit
flag 13 is set indicating masking, the value stored in the
Local Header will be zero.

This does not really solve my problem, what's MS-DOS Format? And waht
is meant with "last mod" - just forget the high-order bytes?

> Yes, you need a central directory if you want a valid zip file that
> other programs can read.


Ok, thanks.

I see the zlib.dll has minilib which can directly create zip files.
Perhaps this would facititat the whole thing.

Jens

Mark Adler

2007-03-22, 9:55 pm

On Mar 22, 8:30 am, mueller.j...@gmail.com wrote:
> This does not really solve my problem, what's MS-DOS Format?


You are correct that the specification doesn't describe that. A quick
search on google though turns it up. Here is one example:

http://www.vsft.com/hal/dostime.htm

> And waht
> is meant with "last mod"


"mod" means modification. So it means the last modification date and
time of the file.

> I see the zlib.dll has minilib which can directly create zip files.


That may depend on which zlib dll you have -- there are several
different things out there called "zlib.dll". You would be better off
using one that you know has minizip in it. From the DLL FAQ on the
zlib.net site:

Gilles Vollant has contributed a build named ZLIBWAPI.DLL,
with the ZLIB_WINAPI macro turned on, and with the minizip
functionality built in. For more information, please read
the notes inside "contrib/vstudio/readme.txt", found in the
zlib distribution.

Mark

Jens Müller

2007-03-22, 9:55 pm

> "mod" means modification. So it means the last modification date and
> time of the file.


Oh, I thought it was the arithmetic operation!

> Gilles Vollant has contributed a build named ZLIBWAPI.DLL,
> with the ZLIB_WINAPI macro turned on, and with the minizip
> functionality built in. For more information, please read
> the notes inside "contrib/vstudio/readme.txt", found in the
> zlib distribution.


Thanks, this could help me!

Jens

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com