English 中文(简体)
"Untar" file on iPhone
原标题:

I m writing an iPhone app which downloads a tar-gzipped file from a Webserver, then needs to unarchive this file so that it can be copied into the app s Documents folder.

I m using tar/gzip because I want to download a whole bunch of small files in one HTTP request, to make everything nice and fast.

I ve investigated solutions like http://www.feep.net/libtar/, but as a C/Objective-C newb, I can t get any of them to compile for the iPhone platform.

(I felt like I should just be able to do a system call to "tar -zxvf myfile.tar.gz", but it would appear it s not that easy!)

So is there a simple way to just un-tar a file on the iPhone? Or am I going about this all wrong, and is there a better way to do this?

Thanks in advance!

Nik

最佳回答

This blog post should help you: http://blog.hawkey.org/?p=332

EDIT: Google cache version of the same page which actually links to a forum post here which links to a Google Code project here, containing some code which implements unzipping on iOS.

问题回答

Here is a light untar library for iOS : https://github.com/mhausherr/Light-Untar-for-iOS

Complete blog post about the solution : http://blog.octo.com/en/untar-on-ios-the-pragmatic-way/

Hope this helps, Vincent

I took a different approach by building libarchive and bz2lib as a static library for iOS. You can find it here:

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





相关问题
How to determine compressed size from zlib for gzipped data?

I m using zlib to perform gzip compression. zlib writes the data directly to an open TCP socket after compressing it. /* socket_fd is a file descriptor for an open TCP socket */ gzFile gzf = gzdopen(...

Transparent SQLite Data Compression

I am looking for an existing solution for transparent SQLite 3 zlib compression using a custom VFS implementation and a custom IO methods implementation. Is anyone aware of an existing project that ...

"Untar" file on iPhone

I m writing an iPhone app which downloads a tar-gzipped file from a Webserver, then needs to unarchive this file so that it can be copied into the app s Documents folder. I m using tar/gzip because I ...

Compress data before storage on Google App Engine

I im trying to store 30 second user mp3 recordings as Blobs in my app engine data store. However, in order to enable this feature (App Engine has a 1MB limit per upload) and to keep the costs down I ...

Unzipping part of a .gz file using python

So here s the problem. I have sample.gz file which is roughly 60KB in size. I want to decompress the first 2000 bytes of this file. I am running into CRC check failed error, I guess because the gzip ...

热门标签