Zlib implementation Part II

Fled
Fled used Ask the Experts™
on
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 : ?
            end;

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.
Comment
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:

e.g:

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 }
fcStream.writeText('v0.30');
{ write orig file name }
fcStream.writeText(orig_filename);
{ 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;
zlibbedStream.copyFrom(fcStream,dataSize);

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

Hope it helps
Peter
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.

Regards,
Alex.

Author

Commented:
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...

Thanks

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.

Author

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

Author

Commented:
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