BlackBerry - Unpack Zip File

Tag: blackberry , compression , zip Author: xbliss Date: 2009-11-02

I'm developing a BlackBerry application in which I need to unpack a zip file compressed with PKZIP. The package could have one file in it, or it could have 10; it will vary in each case. I know that the BlackBerry API has native support for GZip and Zlib, although I'm pretty sure that these methods aren't going to be helpful in my case. It doesn't look as if I can extract the individual files using these calls.

I've tried JZlib (http://www.jcraft.com/jzlib/), which compiled fine, but again it doesn't look as if the methods contained therein are going to allow me to pull the individual files.

It appears as if this is possible, as there's an application called Ziplorer (http://www.s4bb.com/software/ziplorer/) that claims to do perform this exact procedure. How they're doing it, however, escapes me.

So here I am after hours of Googling. I'm welcoming any insight into my problem with open arms.

Have you considered licensing issues with releasing you application for (i assume) profit while using a gnu or open source licensed resource?
The application will actually be free, so I don't believe there will be any licensing issues there.

Other Answer1

"zip" algorithms are typically offshoots of the Lempel-Ziv-Welch algorithm. They are a fairly efficient stream compression algorithms, but because of how they function, you can't start to decompress at random points in the file, you have to start from the start.

Any product that claims to be able to decompress one file from a zip still has to decompress everything before it in the zip file in order to know how to decrypt the given file, or even, for that matter, where the file is in the archive.

comments:

While true, this isn't an answer to the original poster's question. There are lots of zipfile APIs/libraries around that will retrieve a single file from inside the archive - e.g. Python's zipfile library. Trivially, you can do it by starting at the start, decoding and throwing away anything that isn't the file you want.

Other Answer2

If you can tolerate GPL code in your application, then this library http://jazzme.sourceforge.net/ that might work. However the project (and its parent project http://sourceforge.net/projects/jazzlib/) don't look like they're being developed.