rubenv / zipper

Insanely simple zipfile creator for node.js.
http://savanne.be/445-zipper-an-insanely-simple-zipfile-creator-for-node-js
Other
33 stars 6 forks source link

Zip a folder #2

Open ghost opened 12 years ago

ghost commented 12 years ago

Can I call addFile and add an entire folder structure Recursively? I am a little confused!

For example I want to zip the folder:

folder --> one.txt --> two.txt --> three.txt

and maintain the folder structure!

rubenv commented 12 years ago

This is not supported yet. Basically we'd have to expose zip_add_dir, which creates a folder. Then you'd be able to pass in filenames such as "myfolder/myfile.txt".

Sounds like something that could be useful though!

ghost commented 12 years ago

I wrote this real quick and it accomplishes what I need it to and may be useful to some one else. Right now it is super ugly I just ripped it right out of a project that needs to be finished! https://gist.github.com/1773875

If you think it is worth it I could put it into the project formally. Let me know what you think =)

ghost commented 12 years ago

Hey,

I was looking at this problem some more and had some thoughts.

I need to zip a folder structure recursively and could not find a library that did this. It is possible for me to use a format other then zip. Is there some other library I should be looking at.

If not do you think I should extend this project to handle this case?

rubenv commented 12 years ago

I'm pretty sure other people would find this useful. Additions are always welcome :-)

gitfy commented 12 years ago

Hey, I need this feature too (zipping a folder - preserving the structure). When will this be available ?

Thanks.

ghost commented 12 years ago

I will have a version of it on my branch by I would say Tuesday. I have to clean get through something else before I can finish it.

If you want to try to go it yourself the hardest part of the function is here https://github.com/RumpleFraggle/spo/blob/master/lib/spo.js#L255 which will dump the structure to a JSON array that you can then pass to the files function. Which is here https://github.com/RumpleFraggle/zipper

If you do try it yourself watch out for special files pipes circular links etc chilen in the directory ( and watch out for the goofy way the JSON comes out )

ghost commented 12 years ago

Hey gitfy, Didn`t forget about you =) I am getting there!