# Zip an entire folder

**URL:** <https://discourse.libcinder.org/t/zip-an-entire-folder/634>\
**Category:** Using Cinder\
**Created:** [April 3, 2017, 4:04pm UTC](https://discourse.libcinder.org/t/zip-an-entire-folder/634 "2017-04-03T16:04:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dazzid](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/dazzid/32/158_2.png) [@Dazzid](https://discourse.libcinder.org/u/Dazzid)\
**Post date:** [April 3, 2017, 4:04pm UTC](https://discourse.libcinder.org/t/zip-an-entire-folder/634/1 "2017-04-03T16:04:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [April 3, 2017, 7:11pm UTC](https://discourse.libcinder.org/t/zip-an-entire-folder/634/2 "2017-04-03T19:11:42Z")

</div>

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](http://www.zlib.net/zlib_how.html).

Cinder’s `Buffer` class has [methods](https://github.com/cinder/Cinder/blob/master/src/cinder/Buffer.cpp#L129-L222) 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

---

<div class="post-metadata">

**Author:** ![Dazzid](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/dazzid/32/158_2.png) [@Dazzid](https://discourse.libcinder.org/u/Dazzid)\
**Post date:** [April 3, 2017, 9:25pm UTC](https://discourse.libcinder.org/t/zip-an-entire-folder/634/3 "2017-04-03T21:25:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ryanbartley](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/ryanbartley/32/5_2.png) [@ryanbartley](https://discourse.libcinder.org/u/ryanbartley)\
**Post date:** [April 3, 2017, 9:40pm UTC](https://discourse.libcinder.org/t/zip-an-entire-folder/634/4 "2017-04-03T21:40:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Dazzid](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/dazzid/32/158_2.png) [@Dazzid](https://discourse.libcinder.org/u/Dazzid)\
**Post date:** [April 3, 2017, 9:47pm UTC](https://discourse.libcinder.org/t/zip-an-entire-folder/634/5 "2017-04-03T21:47:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![balachandran\_c](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@balachandran\_c](https://discourse.libcinder.org/u/balachandran_c)\
**Post date:** [April 4, 2017, 5:04am UTC](https://discourse.libcinder.org/t/zip-an-entire-folder/634/6 "2017-04-04T05:04:31Z")

</div>

Hi,

[Libarchive](https://github.com/libarchive/libarchive/wiki/Examples#A_Basic_Write_Example) should help you create an archive with multiple files. It should work with gzip/bzip2/lzma formats.

Bala.
