Zip an entire folder


#1

Hi all,
I am wondering with cinder (boost) would be complicated to zip an entire folder with .csv, .aiff and .mp4 files on it. I’m planning to do an automated uploader to a online repository of my data, but need to zip the files to upload them.
Thanks for the suggestions
best
David


#2

Caveat: never tried it myself.

Cinder comes with the zlib library, so you should be able to use the methods defined in there to compress and decompress files. For general info, see their docs.

Cinder’s Buffer class has methods that make use of zlib, called compressBuffer and decompressBuffer. If you first read a file into the buffer, then compress and write it, you should have a proper ZIP file.

-Paul


#3

Ok thanks for the answer, just another question, zlib allows me to compress an entire folder with files on it? Somehow reading the examples it only makes references to a single file compressed. Don’t see any method to add files to the compressed result.
Best
David


#4

Does this need to happen in runtime cplusplus? It would probably take 3 lines of bash or 10 lines of python to do this. Is there a reason you need to use cinder?


#5

Ryanbartley, you are totally right, and actually it seems to be not trivial on c++. The reason is because I’m currently working on a small team that is developing an app that record audio, sensors among other; great part of the app is done already on C++, trying not to build a parallel standalone.


#6

Hi,

Libarchive should help you create an archive with multiple files. It should work with gzip/bzip2/lzma formats.

Bala.