Unzipping a single file from Archive

穿精又带淫゛_ 提交于 2019-12-02 07:40:42

问题


I'm trying to port an existing Android application to iOS, In the Android application i was using a ZipInputStream to extract a single file from the zip archive and store it in as a temporary file.

How could i extract a single file from a Zip Archive without having to extract the whole archive (As it is very large)?


回答1:


I just found the answer,

I had to modify SSZipArchive to insert a method that will extract a single file from the ZIP archive (Based on its name)

You could find the modified version here, if someone finds this useful i might clean it up, add the delegate, the tests and propose for pull in SSZipArchive.

Usage is straightforward:

NSString *zipEntityToExtract = @"example.aac";
NSString *destinationFilePath = ...; //(Includes filename)
NSString *zipPath = ...;
[SSZipArchive unzipEntityName:zipEntityToExtract fromFilePath:zipPath toDestination:filePath];
//File is now in destinationFilePath


来源:https://stackoverflow.com/questions/25016006/unzipping-a-single-file-from-archive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!