I've implemented Apple Archive in the app I'm working on and have implemented lzfse algorithm. The framework is extremely impressive in terms of the speed and compression ratios. I'm using the closure in ArchiveStream.writeDirectoryContents to indicate what the current file is being processed, but there doesn't seem to be a way to pull out progress % on each file. I've seen examples here [Accelerate].(https://developer.apple.com/documentation/accelerate/compressing_and_decompressing_files_with_stream_compression) but these aren't using the Apple Archive Framework... I'd really like to stick with the Apple Archive Framework if possible as it's simple and very fast.
Apple Archive Progress
I'm using the closure in
ArchiveStream.writeDirectoryContents
to indicate what the current file is being processed
Presumably that means that you’re archiving a bunch of files, some of which are large, and you want progress within the large ones?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Yes, that's correct. As an example, if archiving a folder with 20 files ranging from 1MB to 40GB in size, I'd like to get overall progress as well as progress percent per file if possible with this framework. Thank you.
Thanks for confirming.
My initial hope was that Apple Archive would support Foundation’s Progress
model but that’s not the case )-: You should feel free to file an enhancement request for that.
As a next step I dug into the framework in some depth. Unfortunately the answer isn’t what I was hoping for. Apple Archive does support intra-file progress via the .encodeWriting
message. If you look at the header doc for the equivalent C constant, AA_ENTRY_MESSAGE_ENCODE_WRITING
, it says:
If not
NULL
,data
is a pointer to twouint64_t
values containing the total DAT blob size, and the currently processed DAT blob size. For files with large data blobs, this callback will be received several times to allow progress tracking and cancellation. If the callback returns a negative value, the current operation will be aborted as soon as possible.
which is exactly what you need. In the Swift interface the equivalent is the EntryMessage
and EntryFilterData
values passed to your filter closure. But… while there is an .encodeWriting
message, there’s no corresponding value in the EntryFilterData
enum )-:
There’s no fundamental issue here. Rather, it’s just that the Swift wrapper needs to be updated to pass this value through. My advice is that you file a bug requesting that.
In the meantime, the obvious, albeit un-fun, workaround is to switch to using the C interface )-:
If you do file any bugs here, please post their numbers, just for the record.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"