How to read files in the Zip/Jar file? using (either C or C++)

Hi friends..

i am tasked to read one file or all files in particular zip / jar file using C or C++..
so, i can choose which file in the Zip / Jar that need to be read by my C Application..
how to getting started to solve this?

Please help me regarding this.

Thanks.
You need a library that does the proper decompression. I recommend zlib.
http://zlib.net/

Take a look in the "contrib/minizip" subdirectory to see how to handle .zip files. (A .jar file is just a .zip file with a different extension.)

Good luck!
Hi Duoas..

Thanks for your reply..
Sorry, i'm pretty new using zlib..
I have already downloaded zlib 1.2.5..
Please tell me what the steps to use zlib in our C / C++ Application..
And if you don't mind, please give me an example application or link for zlib's usage..

Please help me regarding this..

Thanks in advance..
There is a manual at the link Duoas gave you.
man... I made a .zip file reader/writer in my old now defunct lib.

I should remake something like that (with the fat trimmed) and release it.
@Disch
Yes, yes you should.
It was a pretty sweet setup. I had a FileSystem abstraction. The actual filesystem was derived class, and zip files were another derived class, so you could use zip files and the actual file system interchangably. It worked great for what I needed it for at the time.

It also had a cache system where files were decompressed once then possibly stored in a cache so that if the same file was read again at a later time it wouldn't need to be decompressed. Worked well with file seeking too.

About the only thing it didn't have was locking portions of a file. Also I don't think it was thread safe. If I redo it I'd probably consider those in more detail.


But yeah it was all abstracted really well too so like other archive formats could be dropped in pretty easily.
closed account (z05DSL3A)
Disch wrote:
I made a .zip file reader/writer ... I should remake something like that ... and release it.
Why not make a community project and host it github (or similar)?
Topic archived. No new replies allowed.