mxcl / Path.swift

Delightful, robust, cross-platform and chainable file-pathing functions.
The Unlicense
946 stars 36 forks source link

Consider making TemporaryDirectory public? #23

Closed alexito4 closed 5 years ago

alexito4 commented 5 years ago

Hi,

I was checking out swiftsh code and found Path.mktemp which is really useful, but when trying to use it I was surprised is not available in Path. I see that in this library is just used as an helper for the tests but swiftsh uses it for production code in eject.

Would you consider making TemporaryDirectory part of the Path API? Or is there any reason why that's a bad idea?

Cheers

mxcl commented 5 years ago

Hi, TemporaryDirectory was public, but I removed it: cd30e8.

I did this because I didn't consider it within the responsibility boundary of this library. An entire library could be dedicated to temporary directories (and files) and thus would have better API and a more thorough implementation.

A good example of a better implementation is SwiftPM’s Utility library. Not that I think anyone should use that, but it's better for this particular area.

Thanks.

alexito4 commented 5 years ago

That makes sense thanks 👍

For SwiftPM, you refer to this file? TemporaryFile.swift

we can close this then 😉

Cheers

mxcl commented 5 years ago

Yeah that one. You can import it if you depend on the whole of SwiftPM, but that's why I say I wouldn't recommend it since it imports a lot of other stuff, and Apple themselves say you shouldn't depend on libUtility.

Thanks for the report, I consider this an area I may in future make a separate library for, in the mean time feel free to vendor the file!