Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library for extracting zip on the fly

Tags:

c++

c

zip

in-memory

I have a rather large ZIP file, which gets downloaded (cannot change the file). The quest now is to unzip the file while it is downloading instead of having to wait till the central directory end is received. Does such a library exist?

like image 436
abergmeier Avatar asked Oct 21 '22 17:10

abergmeier


2 Answers

I wrote "pinch" a while back. It's in Objective-C but the method to decode files from a zip might be a way to get it in C++? Yeah, some coding will be necessary.

http://forrst.com/posts/Now_in_ObjC_Pinch_Retrieve_a_file_from_inside-I54 https://github.com/epatel/pinch-objc

like image 142
epatel Avatar answered Oct 24 '22 10:10

epatel


I'm not sure such a library exists. Unless you are on a very fast line [or have a very slow processor], it's unlikely to save you a huge amount of time. Decompressing several gigabytes only takes a few seconds if all the data is in ram [it may then take a while to write the uncompressed data to the disk, and loading it from the disk may add to the total time].

However, assuming the sending end supports "range" downloading, you could possibly write something that downloads the directory first [by reading the fixed header first, then reading the directory and then downloading the rest of the file from start to finish]. Presumably that's how "pinch" linked in epatel's answer works.

like image 24
Mats Petersson Avatar answered Oct 24 '22 09:10

Mats Petersson