Skip navigation.
 
mlRe: ZIP archives
FROM : Matt Mashyna
DATE : Wed Jul 26 00:24:44 2006

I rolled my own zip compressor a few years ago for Carbon and then re-rolled
it a few months ago for Cocoa. It wasn't as much work as you might think. I
used the zlib 1.3 distribution, figured out what files I needed and added them
to my project. I don't think they needed much, if any, tweaking. You need to
make a function to get the file time and attributes, and a function to
calculate the MacBinary CRC.

I created a zip helper class that creates an archive and allows you to add
files to it. Later I updated it to do bin hexing without much more work. All
you do is append the file name with a .bin extension then write the header
followed by the forks instead of only the data fork.

I made a path crawler class to feed the zip helper files. Adding folder
hierarchies instead of flat files is a little tricker but not much. You want
to include relative paths in the filenames as you add them to the archive.

Disclaimer: While I zip files I don't unzip them in my app. I know I can unzip
them on Windows and OS X.

Here's the list of files in my project (more headers are included in the
distribution source but not in my project):
zip.c
inftrees.c
inflate.c
zutil.c
uncompr.c
infblock.c
adler32.c
inffast.c
infcodes.c
deflate.c
crc32.c
trees.c
infutil.c
gzio.c
compress.c

Matt Mashyna
The Frodis Co.

> I am wanting to implement in my app the ability to create
> standard .zip archives.  I have looked through the list archives and
> read various things on the internet, but I'm rather confused :(
>
> Thus far my research has uncovered to me:
>
> zlib - pre-installed with OS X.  Does not support .zip archives, but
> there is add-on code to do it.
>
> gzip - Also doesn't support .zip archives
>
> info-zip - As far as I can tell, this is an open source command line
> tool, rather than a library I can use.
>
>
> So, what would people recommend for Cocoa use?  Should I use NSTask
> to have a command line tool handle the thing for me?  Or should I use
> a library like zlib?  Or is there something better that I've missed
> altogether!?
>
> Mike.
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
>

Related mailsAuthorDate
mlZIP archives Mike Abdullah Jul 25, 21:24
mlRe: ZIP archives Alan Smith Jul 25, 21:35
mlRe: ZIP archives Scott Thompson Jul 25, 21:38
mlRe: ZIP archives I. Savant Jul 25, 21:39
mlRe: ZIP archives Nick Zitzmann Jul 25, 22:08
mlRe: ZIP archives I. Savant Jul 25, 22:19
mlRe: ZIP archives Joshua Scott Emmon… Jul 25, 22:31
mlRe: ZIP archives Nir Soffer Jul 25, 22:51
mlRe: ZIP archives Matt Mashyna Jul 26, 00:24
mlRe: ZIP archives Michael Hall Jul 26, 00:44
mlRe: ZIP archives Ryan Britton Jul 26, 01:02
mlRe: ZIP archives Dragan Mili? Jul 26, 08:29
mlRe: ZIP archives Mike Abdullah Jul 26, 13:44