Apple provides sample code for compressing a single file here, but the "aa" command and Finder cannot decompress these files. I needed to write a custom decompresser using Apple's sample code here.
Apple provides sample code for creating an "aar" file for directories here and a single string here, and the aa command and Finder can deal with these.
However, I have struggled creating an ".aar" file for a single file.
The file could be quite large, so reading it into memory and writing it as a blob is not an option.
Does anyone have suggestions or can point me to Apple documentation that can create a ".aar" file for a single file?
Coming at this from the perspective of the C API, the equivalent of writeDirectoryContents(archiveFrom:path:keySet:selectUsing:flags:threadCount:) is the combination of AAPathListCreateWithDirectoryContents and AAArchiveStreamWritePathList. And to write a single file you can create the path list with AAPathListCreateWithPath.
The Swift API combines these two into a single step, so there’s no Swift equivalent of AAPathListCreateWithPath. However, it’s not clear whether you need that. If you put a file in a directory and then point writeDirectoryContents(…) at that directory, you end up with an archive that contains just that file. For example, with this hierarchy:
/Users/
quinn/
Test/
somefile.text
passing /Users/quinn/Test to writeDirectoryContents(…) I end up with this:
% aa list -v -i output.aar
Operation: list
worker threads: 14
verbosity level: 1
input file: output.aar
entry types: bcdfhlmps
D PAT= UID=502 GID=20 MOD=00755 FLG=0x00000000 CTM=1663853978.872477459 MTM=1771930096.106661813
F PAT=somefile.text UID=502 GID=20 MOD=00644 FLG=0x00000000 CTM=1771867732.937172055 MTM=1771868833.352496645 DAT[3971]
0.00 total time (s)
which seems pretty reasonable.
Is that what you’re looking for? Is the presence of that directory (D) entry a problem?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"