Compressing the folder


#1

Hi Jules,

How can one compress the folder. There is “GZIPCompressorOutputStream” class, but using it i cant compress the folder. One thing i can do is just write files from folder as stream.
Is there a way to compress the folder so that uncompressing it will yield me the original files.

Regards,
Godwin


#2

as far as I know, GZIP format doesn’t store directory structure, so you can compress/decompress only a single file per GZIP file.
That’s why, on unix platforms, it’s common to see TAR archives (which store a folder into a single file) that are GZIPped.


#3

i had the same problem, but i wrote a small class to write zip files, you can just add File() objects to it and it will spit out a zip file with those file in it, it has a amalgamated minizip.c library to do the zip write stuff, it works for me. the code is here

http://edoapp.googlecode.com/svn/trunk/src/Core/EdoZipWrite/


#4

Thanks for the reply Atom

Did u write the code foe mac as well…
I m on cross platform so i need the mac code as well…

Thanks and Regards
Godwin


#5

i guess it should be, the minizip library works on linux and win32 i see no reason it wouldnt work on mac (osx has zlib installed by default) and the class is pure JUCE so that will work definetly. i dont have a mac to check.


#6

There is variables of type HANDLE and other type in the minizip.c file…
And due to that its not compiling in mac…


#7

it’s because iowin32.h is bundled in there, just add a IFDEF WIN32 before the
/********* Start of inlined file: iowin32.c *********/

and you should be set, if not just get minizip http://www.winimage.com/zLibDll/minizip.html from here and use thhat, this is just my version.


#8

Actually i saw it … And i was initially working on mac i commented out the windows code … and it was compiling and it was giving linker error…
Confused about which library to add to project i dropped that plan…

I just used zip command with system command for mac and i created process for WINZIP32.exe to create the zip file in windows.

Anyway it was for internal use… So no worries.


#9

there is no library to add, juce has ZLIB embedded yiu just need to point the minizip library to zlib.h in thhe juce directory (that’s what i do) and i don’t need to link to anything external since all the ZLIB symobls are in juce, so the minizip works out of the box.

that’s how i do it on win32 and linux.


#10

This worked great for me - thanks atom.


#11

Update : just use ZipFile class in JUCE


#12