saagarjha / unxip

A fast Xcode unarchiver
GNU Lesser General Public License v3.0
867 stars 39 forks source link

Ability to set Working Directory/Output for library #36

Open MattKiazyk opened 12 months ago

MattKiazyk commented 12 months ago

I could very well be missing something, but I can't seem to figure out how to set the working directory when using the libunxip

Using the simple


let handle = try FileHandle(forReadingFrom: input)
let data = DataReader(descriptor: handle.fileDescriptor)

for try await file in Unxip.makeStream(from: .xip(input: data), to: .disk, input: data) {
   print("file: \(file.name)")
}``` 

I can see it working but unsure where (if at all) it's putting those files?

What am I missing? 
saagarjha commented 11 months ago

I should probably change this at some point but unxip currently just writes relative to the current working directory. If you want to change this you should use chdir like I do here: https://github.com/saagarjha/unxip/blob/3169e60aabe2d4b7fbadb9a3670e9ab6946aeef4/unxip.swift#L1589

(And perhaps undoing this once you're done)