A free LGPL compression libary?

A

Aleksi Suomalainen

Hello!

Is there any LGPL licensed C++ compression library that supports
multiple file compression and is supported in Linux and Windows?

I know zlib is one, but gzip can only compress 1 file, AFAIK. (If anyone
could tell me how multi file compression can be done, then I'll use Zlib)

LoCusF aka Aleksi Suomalainen
 
S

stefan.ciobaca

You just merge all files together and then use zlib on the result.
How is that for an answer?
 
R

Rolf Magnus

Aleksi said:
Hello!

Is there any LGPL licensed C++ compression library that supports
multiple file compression and is supported in Linux and Windows?

I know zlib is one, but gzip can only compress 1 file, AFAIK. (If anyone
could tell me how multi file compression can be done, then I'll use Zlib)

Use some archive format that puts multiple files together into one big file.
Then you can compress that file. The most widely used is probably tar. The
file format is quite simple.
Btw: If you can live with longer (de)compression times and a BSD licensed
library, you can use libbz2 instead of zlib. This has better compression
ratio.
 
A

Aleksi Suomalainen

Hello!

I have tried that but it isn't reasonable since the files that I
compress are xml, and its pain to separate them for parsing.
 
J

Jerry Coffin

Hello!

Is there any LGPL licensed C++ compression library that supports
multiple file compression and is supported in Linux and Windows?

www.info-zip.org

The only deviation is that its license isn't nearly as restrictive as
the GPL or LGPL, but it's hard to believe that would bother much of
anybody.
 
E

Eric Jensen

I have tried that but it isn't reasonable since the files that I compress
are xml, and its pain to separate them for parsing.

Lets say you have 3 files you want to compress and archive into the same
file.
Then first compress the first file, write the compressed data into your
archive file and save the amout of bytes the compressed data uses in some
collection. Then do the same for the next 2 files. Now that all data is
compressed and written to the archive, you'll need to write a TOC where you
can use the saved sizes to calculate wich position a file starts and ends
at, and so on. When you created the TOC and written it to the file, you can
finally write the size of the TOC in the last bytes in the file, and that
way you will know where the TOC starts when you need to uncompress one or
more files.

Or to make it more easy to start with you can create a seperate file for the
TOC.
Compress files, save sizes, start and stop position in file and dump them
all into one file. Then in a seperate file you could in text mode create a
TOC with a syntax like:

filename startpos endpos

then file size will be (endpos - startpos).

When you want to uncompress you will read the TOC file.
Create a new file with the filename from the toc file, "fast forward" the
file to startpos, and start reading and decompressing until you reach
endpos.

When that is working for you then you could try to merge a toc into the
compressed archive.

//eric
 
A

Aleksi Suomalainen

Eric said:
Lets say you have 3 files you want to compress and archive into the same
file.
Then first compress the first file, write the compressed data into your
archive file and save the amout of bytes the compressed data uses in some
collection. Then do the same for the next 2 files. Now that all data is
compressed and written to the archive, you'll need to write a TOC where you
can use the saved sizes to calculate wich position a file starts and ends
at, and so on. When you created the TOC and written it to the file, you can
finally write the size of the TOC in the last bytes in the file, and that
way you will know where the TOC starts when you need to uncompress one or
more files.

Or to make it more easy to start with you can create a seperate file for the
TOC.
Compress files, save sizes, start and stop position in file and dump them
all into one file. Then in a seperate file you could in text mode create a
TOC with a syntax like:

filename startpos endpos

then file size will be (endpos - startpos).

When you want to uncompress you will read the TOC file.
Create a new file with the filename from the toc file, "fast forward" the
file to startpos, and start reading and decompressing until you reach
endpos.

When that is working for you then you could try to merge a toc into the
compressed archive.

//eric
Ok :), but I have solved the problem already.
 
Y

Yellow Dog

Hello!

Is there any LGPL licensed C++ compression library that supports
multiple file compression and is supported in Linux and Windows?

I know zlib is one, but gzip can only compress 1 file, AFAIK. (If anyone
could tell me how multi file compression can be done, then I'll use Zlib)

LoCusF aka Aleksi Suomalainen

Try doing a search on www.codeproject.com or www.sorceforge.org there
are several wrappers for ZLIB that will read ZIP files. In fact, zlib
comes with a reader called minizip that will read very simple zip
files.

If it ain't broke....fix it anyway!

[To Email Replies Remove the nospam from the address]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top