# Loading zip compressed files

**URL:** <https://discourse.libcinder.org/t/loading-zip-compressed-files/431>\
**Category:** Uncategorized\
**Created:** [December 5, 2016, 10:47pm UTC](https://discourse.libcinder.org/t/loading-zip-compressed-files/431 "2016-12-05T22:47:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharkbox](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/sharkbox/32/39_2.png) [@sharkbox](https://discourse.libcinder.org/u/sharkbox)\
**Post date:** [December 5, 2016, 10:47pm UTC](https://discourse.libcinder.org/t/loading-zip-compressed-files/431/1 "2016-12-05T22:47:17Z")

</div>

Hey guys.  
Playing around with opening up a compressed file inside of cinder. Looking at the buffer class, there is a decompressBuffer function which seems to allow for gzip decompression. Here is the relevant line in the cinder source [https://github.com/cinder/Cinder/blob/master/src/cinder/Buffer.cpp#L148](https://github.com/cinder/Cinder/blob/master/src/cinder/Buffer.cpp#L148) . This is how I’m trying to do it.

```
auto inFile = loadFile("compressedTextFile.txt");
Buffer loadedBuf(inFile);

Buffer decom = decompressBuffer(loadedBuf, true, true);
string dString( static_cast<const char*>( decom.getData() ) );

console () << loadedBuf.getSize() << endl; // the correct size
console () << decom.getSize() << endl; // this is 0

```

My decompressed buffer is always 0. Am I doing this wrong? For reference, I can type “unzip compressedTextFile.txt” in the terminal and it will unpack correctly.

Thanks!  
-c

---

<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:** [December 6, 2016, 6:58am UTC](https://discourse.libcinder.org/t/loading-zip-compressed-files/431/2 "2016-12-06T06:58:25Z")

</div>

Hi,

Could you check the format of the compressed file?

> file compressedTextFile.txt

It seems decompress works for files created with gzip. Not zip.

Does not work:

> file myfile.zip  
> Zip archive data, at least v2.0 to extract

Does work:

> file myfile.gz  
> gzip compressed data, was

Bala.

---

<div class="post-metadata">

**Author:** ![sharkbox](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/sharkbox/32/39_2.png) [@sharkbox](https://discourse.libcinder.org/u/sharkbox)\
**Post date:** [December 6, 2016, 4:15pm UTC](https://discourse.libcinder.org/t/loading-zip-compressed-files/431/3 "2016-12-06T16:15:21Z")

</div>

Yup, it is indeed Zip archive data. Good to know, and thanks!
