Zlib implementation Part II

Fled used Ask the Experts™
Is it possible to write the compressed file into some sort of structured file in which I could also put file version, original file name and some other things like

TcompRec = record
              strFileVersion : string[3] ;
              strOriFileName : string[255] ;
              compressedData : ?

TCompFile file of TcompRec ;

In the mean time, is it possible to record, delete and update multiple files into an archive file like Winzip with Zlib

Francois Leduc
Laval, Qc, Can.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I would say the easiest way to archive many files with zlib is to have a list of many zlibbed files:


zlibbedFiles.items[1] etc...

Each item is an individually zlibbed file...
I know there would be slightly lower compression than zlibbing them all together, but its easier.

Or perhaps zlib each file individually, and then zlib the zlibbed files.  Then when you want to extract a single file, un-zlib the whole lot, then extract the file you want and un-zlib that...

Let me know if you would likew source code for any of these.

As for the first question, I have a stream descendent which would help with what you want.  It works like this:

{ write version }
{ write orig file name }
{ write zlibbed data size, then raw data from stream }
fcStream.writeInt( zlibStream.size );
fcStream.copyFrom( zLibStream, zlibStream.size );
{ write all to disk }
fcStream.saveToFile( zlibRecordFilename );

Then when reading it back:

{ read from disk }
fcStream.loadFromFile( zlibRecordFilename );
{ determine version }
version := fcStream.readText;
{ determine orig filename }
filename := fcStream.readText;
{ get zlibbed data }
dataSize := fcStream.readInt;

Let me know if you want the code. Leave your em@il and I'll send it...

Hope it helps
Create/open a file stream,
write your header there
attach zlib to that stream and process as many files as you wish...

Just keep track of their names and sizes somewhere and stream this info to the same stream, so that you can find it and use to restore the files in the reverse order.

I did it and it worked like a dream.



Would it be possible to have some code exemple from both of you?

I would like to implement your archive header structure in my application since it would be better to have all these files in a simple structure then to have a multitude or compressed files...


Francois Leduc
Laval, Qc, Can.
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.


Oups! here is my e-mail: flmjc@contact.net
Email sent! Example included Have fun


Great stuff...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial