Enchilada
Enchilada

Reputation: 3919

Cocoa class for TAR archiving and unarchiving files

Has someone written a simple Cocoa wrapper class around tar archiving/unarchiving of files?

I plan on doing it myself, unless someone out there has graciously already done it.

EDIT: Are there any reasons I shouldn't just write a wrapper class around the "tar" terminal command? (via NSTask)? Unless there are any objections, this is what I now plan on doing.

Upvotes: 2

Views: 2954

Answers (2)

Regexident
Regexident

Reputation: 29552

Before doing it (at least the unarchiving, that is) yourself I'd recommend taking a look at The Unarchiver's source.
It supports Zip, Tar-GZip, Tar-BZip2, RAR, 7-zip, LhA, StuffIt, etc.


Alternatively for full archiving/unarchiving support there is libarchive,
which is BSD licensed and written in C: http://code.google.com/p/libarchive/
(There even is a static library fork of libarchive for use in iOS)

Filter Support

  • gzip (read and write, uses zlib)
  • bzip2 (read and write, uses bzlib)
  • compress (read and write, uses an internal implementation)
  • uudecode (read only)
  • separate command-line compressors with fixed-signature auto-detection
  • xz and lzma (read and write using liblzma)
  • lzma (if you lack liblzma, you can get read-only lzma support through the lzmadec library; this will likely be dropped as soon as liblzma is stable and widely-available)
  • Starting with libarchive 2.7, most of the above will fall back to using command-line tools if the libraries were unavailable at build time. Note that the command-line tools are usually slower than using the libraries directly.

Archive Formats Supported

  • tar (read and write, including GNU extensions)
  • pax (read and write, including GNU and star extensions)
  • cpio (read and write, including odc and newc variants)
  • ISO9660 (read only, including Joliet and Rockridge extensions, with some limitations; write support starting with libarchive 2.9)
  • Zip (read only, with some limitations, uses zlib; write support starting with libarchive 2.8)
  • mtree (read and write, uses OpenSSL libraries for creating and verifying cryptographic hashes)
  • shar (write only)
  • ar (read and write, including BSD and GNU/SysV variants)
  • empty (read only; in particular, note that no other format will accept an empty file)
  • raw (read only, starting in libarchive 2.8)
  • xar (read only, starting in libarchive 2.8)

Just for the record: Apple private API rejection with libarchive (question was solved, btw)

Upvotes: 2

Pras
Pras

Reputation: 243

I have used this. It worked for me... http://code.google.com/p/ziparchive/downloads/detail?name=ZipArchive.zip&can=2&q=

Upvotes: 1

Related Questions