mcFreid
mcFreid

Reputation: 185

Unzipping a directory in C++

I am creating a C++ program that will read a .docx's plain text. My plan of attack is to rename the .docx as a .zip and then unzip. I then will rename the .xml file containing the text of the document as a .txt and parse it out.

Right now I have figured out the renaming which was easy enough. I am now struggling with unzipping. I am very proficient in C++, but this is my first time I have been extending myself to real word applications and using it beyond the STL library.

At first I tried many wrappers for C++ from the zlib library, but have not been able to get any of them to compile or work properly (it may be due to environment being in Cygwin). For that reason it seems I have to default to using the messy zlib code to do this. But from all the documentation and examples I can find it only shows zlib being used to read a .zip that is a compression of one file not multiple files. I now don't know where to go from here and, like I said earlier, being completely new to the domain outside of STL I am feeling quite lost.

Any help or guidance is much appreciated!

Thanks, Michael

Upvotes: 1

Views: 4057

Answers (3)

Mike McQuaid
Mike McQuaid

Reputation: 9814

zlib is for GZip compression, not ZIP compression (see here for details).

As a result you'd perhaps be better to shell out to the unzip utility provided in Cygwin and available for lots of platforms.

Upvotes: 1

Justin
Justin

Reputation: 9791

I've been dealing with a similar issue, but don't really have a great solution yet.

zlib does not currently support multiple files.

See: C/C++ Packing and Compression

Upvotes: 1

anon
anon

Reputation:

I don't think zlib supports multi-file zips directly (could be wrong), so you may want to look for alternatives. As an aside, you might also want to consider switching from cygwin to MinGW, unless you really need the POSIX/UNIX compatibility that cygwin provides.

Upvotes: 1

Related Questions