saagarjha / unxip

A fast Xcode unarchiver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Separate core extraction logic from CLI tool

trispo opened this issue · comments

It would be great if the code was modularized so that one could only use the extraction logic without the CLI stuff (main, error printing, ...) around. This would enable tools like https://github.com/xcodereleases/xcinfo to use it.

I've been thinking about this as well. An immediate issue that needs needs to be resolved before this can be done is that the code is brittle by design since Apple's XIP format is undocumented, and this simplifies the code. It's not clear to me whether this would be acceptable in a library. As a library author I reserve the right to decide what I am comfortable failing for, but I also feel like the choice I've made currently would not make many clients happy.

A more important concern is that the code steals the cooperative task pool for itself, and it's kind of designed around doing this. This definitely isn't recommended if you need to share that pool, which would be the case if you embedded the code as a library. It might end up being "good enough" in practice; I guess we'll see.

The final thing I'm thinking about is the API I expose. I'm considering taking in a file and giving back an asynchronous stream of Files much like Main.files(in:) returns today. What is your intended usecase for unxip? Would an API like this one be helpful? Would you also like to use the code where I schedule and write files to disk?

The use case I'm thinking of is the automatic extraction of Xcode after downloading it. xcinfo does exactly this and I've integrated unxip experimentally already in the branch called async. But it lacks progress report and errors thrown. For this tool, it is not necessary, to be reported about every single error during extraction. It would be ok if there is an error thrown (eg because of not enough free disk space) and the unxip process stops immediately. I essentially use your main function (renamed to extract) atm.

Not going to close this issue just yet but the current main branch has some work towards a library version of unxip. If you want, give it a spin and see how you feel about it :)

Yeah, great. I'll look into it soon. Many thanks