Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TAR encode/decode library for iPhone (ideally cocoa) [closed]

Does anyone know of any library/code that will enable me to encode and decode .tar formatted data - that I can use in my iPhone project (preferably cocoa)

Thanks in advance

Craig

UPDATE: I've taken a look at the suggested libraries and come to the conclusion that they are making waaaay to much of the problem - so I'm developing the codec myself - it's only a 512byte ASCII header after all - how hard can it be :-)

like image 242
Scotty Avatar asked Jul 30 '09 07:07

Scotty


4 Answers

The best library I've found is libarchive. It is well-designed, well-documented, and fast.

I just created a repository on GitHub that has the tools to build libarchive and libbz2 as static libraries for iOS 4.2+. (It should be possible to use it to target 3.x, too.)

http://github.com/davepeck/iOS-libarchive/

Others have pointed out that libarchive is included in the SDK. This is not quite true. The binary libarchive.2.dylib is included, but the headers are not. The same applies to libbz2 (but, oddly, not to libz.) This means that libarchive is considered a private API -- in other words, you can't use it if you intend to ship on the App Store. Hence my repository.

like image 191
Dave Peck Avatar answered Nov 03 '22 00:11

Dave Peck


In fact, libarchive.dylib is included in the iPhone SDK. You just have to add it. The problem is that somehow Apple did not include the header file archive.h. However, first, you do not need the header files if you know for sure the functions you are going to call exist (though the compiler will whine), second, if you do not want the compiler to complain, you can download the header file for libarchive 2.6 and include it in your program ...

If you want to know know to use libarchive, download its source from the web and study the example given (especially minitar). It is really very straightforward.

like image 39
amadeoh Avatar answered Nov 02 '22 22:11

amadeoh


You might try libxad. This is the library that The Unarchiver, a Mac app, uses.

like image 29
Peter Hosey Avatar answered Nov 03 '22 00:11

Peter Hosey


Even better link: http://code.google.com/p/libarchive/downloads/detail?name=libarchive-2.6.2.tar.gz&can=2&q=

Version 2.6.2 is included in the iOS 4.0 and 4.1 SDK's. It's not present in 3.2 (or earlier I assume).

If you download that, run ./configure --prefix=$HOME && make && make install and you'll find the two header files placed in $HOME/include

like image 45
Matt Connolly Avatar answered Nov 03 '22 00:11

Matt Connolly