tsolomko / SWCompression

A Swift framework for working with compression, archives and containers.
MIT License
237 stars 41 forks source link

Is there a way to extract a single file from a 7z compressed archive? #51

Open breakind opened 8 months ago

breakind commented 8 months ago

I'm using SevenZipEntryInfo to get the list of files in a 7z archive. Is there a way to unzip a specific file individually, rather than unzipping all files using the open method?

tsolomko commented 8 months ago

No, currently there is no such functionality.

breakind commented 8 months ago

Are there plans for this in the future? It may be more appropriate in certain scenarios on mobile devices to operate on individual files separately, especially considering that some files are quite large and the time it takes to decompress all at once is extremely long.

tsolomko commented 6 months ago

While I appreciate the problem, that you have highlighted, in the case of 7-Zip it is a bit tricky to resolve. The issue is that 7-Zip contains inside of it not just files, but "streams" of data (in 7-Zip terminology). Each of the streams can contain the data for multiple files at the same time, and this combined data is compressed together. So, if you want to decompress data for only one file, most likely you will still end up decompressing data for multiple files (the entire stream), or in the worst case, for all the files in the archive.

So it may very well be impossible to speed up the extraction of a single file in the general case.

breakind commented 6 months ago

Thank you very much for your reply.