• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ZIP archives
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ZIP archives


  • Subject: Re: ZIP archives
  • From: "Matt Mashyna" <email@hidden>
  • Date: Tue, 25 Jul 2006 18:24:44 -0400 (EDT)
  • Importance: Normal

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@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: ZIP archives
      • From: Michael Hall <email@hidden>
References: 
 >ZIP archives (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Printing Core Data
  • Next by Date: Re: Custom View Table Views
  • Previous by thread: Re: ZIP archives
  • Next by thread: Re: ZIP archives
  • Index(es):
    • Date
    • Thread