[swift-users] Pure Swift, cross platform way to open, read/write files?

Max Howell max.howell at apple.com
Wed Dec 9 12:25:11 CST 2015


I feel I must point the community at:

https://github.com/apple/swift-package-manager/tree/master/Sources/POSIX

Which is mostly what I think you are calling the lower layer.

>>> A lower layer is also needed -- simple Swifty wrappers for the
>>> Unix system calls so that Swift implementations can get at them
>>> without having to use unsafe constructs. open(2), read(2),
>>> write(2), lseek(2) and close(2) would provide about 75% of what
>>> one needs for the higher layer stuff (and everything one would
>>> want for stdio) with quite minimal hacking.
>> 
>> I agree, but I foresee problems in the future when Swift is ported
>> to Windows. :/
> 
> I'm a big believer in not prematurely generalizing an implementation.
> APIs last a long time, implementations can be redone later. :)



More information about the swift-users mailing list