0

I am searching for a few days a library that just has to move all the files in a ZIP archive, to another in C++. I found libzip, but it it is better just for some files that you know the names. I don't care of the steps between the archive A and the archive B, as long as it doesn't take too much time. (and if possible, it will remove the files in its temporary folder). And I prefer a portable library.

Thanks you!

Tiwenty
  • 733
  • 1
  • 10
  • 17
  • Why not make your life a lot more simpler and write a little script? You can then use the `system` function within your C++ program to execute this script. – Ed Heal Feb 01 '13 at 08:56
  • What system are you on? The answers will vary greatly depending upon unix/windows. – Peter Wood Feb 01 '13 at 09:01
  • Because I would like my program to be portable. If it was only for Linux, it would be easy. But it is also for Windows, and there are no zip/unzip equivalent. – Tiwenty Feb 01 '13 at 09:02

1 Answers1

1

Libzip is probably the best bet.

You can use zip_get_num_entries to get the number of files in an archive, then use zip_get_name to get the file-name of a specific file. Use zip_fopen_index to open a file inside the archive, zip_fread to read the file (and save either to disk or to another zip archive) and when done zip_fclose to close the file. If you want to remove the file from the archive use zip_delete.

Continue to do this in a loop for all files, starting with the highest index down to index zero.


As for libzip on Windows, see e.g. this answer (or if it doesn't work this one).

Community
  • 1
  • 1
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621