开发者

Extract a zip file from a zip archive without loading the whole file into memory

Is there a way to extract a single file from a zip file in Adobe AIR?

I'm using NoChumps zip library to extract files from a zip. In this library the entire IDataStream is loaded into memory and after that you can extract file entries easily. In cases where the zip is 5 to 10MB there are no problems. But when the zip is 80MB, which many are, 80MB is loaded into memory. This causes the app to crash and run slow on mobile devices. According to the zip specification,

"A ZIP file is identified by the presence of a central directory located at the end of the file, this allows appending of new files. The directory stores a list of the names of the entries (files or directories) stored in the ZIP file, along with other me开发者_如何转开发tadata about the entry, and an offset into the ZIP file, pointing to the actual entry data."

Also, I do not have control of the size of zip files but most average is 60 to 100MB. Files inside are ~4MB.


It's not possible for Flex, but possible for AIR. AIR got File class with random access, which allows to read zip file list. I used Coltware's airxzip and it served me well. Create ZipFileReader, open your zip file, call getEntries(), locate entry you need and call reader.unzip(entry).


The quick answer - no it is not possible.

The long answer - you need to make a secondary program that use a library like zLib and have that installed on the machine also

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜