PDA

View Full Version : unzip via C++




nunyabeezwax
Mar 19, 2008, 09:08 AM
I have an application that downloads updates to support files and the application itself from a web server. I want to be able to unzip the file while it is still in memory and then save it uncompressed. Right now I am just saving the zip file and decompressing it manually. I am looking for a code sample or a hint to a function or even a way to do this with BOMArchiveHelper.

Thanks,

John.



ScoobyMcDoo
Mar 19, 2008, 10:33 AM
You can probably find what you need here (http://www.info-zip.org/).

nunyabeezwax
Mar 19, 2008, 11:10 AM
Thanks for the quick reply, but I was looking for an intrinsic solution either via a function or a call to an external program like BOMArchiverHelper.

Thanks,
John

MacsAttack
Mar 19, 2008, 01:59 PM
Why not use the unzip command - should be possible to issue command line calls from within a program...

like this... http://maccoder.blogspot.com/2007/04/interacting-with-command-line-in.html

Guess you could make the call to execute BOMArchiveHelper, but I've found on several occasions that it will not always work with files from Windows systems. The unzip command line utility (included with OS X) is more reliable.

Just fire up the terminal and type "man unzip" to see more

nunyabeezwax
Mar 19, 2008, 03:45 PM
Thanks, that is a great help and I will give it a go but my goal is still to call a function and not a outside program. So if anyone else has a suggestion it would be appreciated.

Thanks again,

John

Cromulent
Mar 19, 2008, 04:38 PM
Thanks, that is a great help and I will give it a go but my goal is still to call a function and not a outside program. So if anyone else has a suggestion it would be appreciated.

Thanks again,

John

Look around for a zip library. It would be much easier though just to use a system() call.

You won't just find a single function solution with a zip file I'm afraid if you go the library route. You'll still need to read the file, process it and write the data back to another file.

Edit : Here you go : http://www.zlib.net/

nunyabeezwax
Mar 19, 2008, 05:48 PM
I have already completed this code for win but when I attempted to compile the zip code for Mac there were plenty of errors. So, I was just thinking that there would be a Mac function(and yes I realized it could be several functions) but I could not find it via my searching so I was relying on help here. The boss isn't real happy about the system call(neither of us has any experience with them) and I didn't want to fix all the errors but I guess I will have to!

Thanks to everyone who helped or anyone else that may have an alternate solution,

John