“解压” iPhone 上的文件
我正在编写一个 iPhone 应用程序,它从网络服务器下载一个 tar-gzip 压缩文件,然后需要取消存档该文件,以便可以将其复制到应用程序的 Documents 文件夹中。
我使用 tar/gzip 是因为我想在一个 HTTP 请求中下载一大堆小文件,以使一切变得又好又快。
我研究过诸如 http://www.feep.net/libtar/ 之类的解决方案,但作为C/Objective-C 新手,我无法为 iPhone 平台编译它们中的任何一个。
(我觉得我应该能够对“tar -zxvf myfile.tar.gz”进行系统调用,但看起来这并不那么容易!)
那么有没有一种简单的方法来解压缩文件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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这篇博文应该可以帮助您:
http://blog.hawkey.org/?p=332
编辑:Google 缓存版本同一页面实际上链接到此处的论坛帖子,链接到 Google Code 项目在这里,包含一些在 iOS 上实现解压的代码。
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.
这是一个适用于 iOS 的轻量级解压库: https://github.com/mhausherr/Light- Untar-for-iOS
有关解决方案的完整博客文章:http://blog.octo.com/en/untar-on-ios-the-pragmatic-way/
希望这有帮助,
文森特
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
我采取了不同的方法,将
libarchive
和bz2lib
构建为 iOS 静态库。您可以在这里找到它:http://github.com/davepeck/iOS-libarchive/
I took a different approach by building
libarchive
andbz2lib
as a static library for iOS. You can find it here:http://github.com/davepeck/iOS-libarchive/