aantron / luv

Cross-platform asynchronous I/O and system calls
https://aantron.github.io/luv
MIT License
275 stars 26 forks source link

Expose mode from Luv.File.Stat.t as an integral or expose equality #134

Open haesbaert opened 1 year ago

haesbaert commented 1 year ago

mode is a Mode.numeric

There is no good way to get the file type, normally you would AND with SIFMT and test for equality with all the S* types. Testing the bits with Mode.test is not enough since the bits are shared between different file types.

Currently the only way I found to figure the filetype was doing:

    let mode = (Obj.magic lst.mode : int) in

And then doing all the mask and comparison myself, see https://github.com/ocaml-multicore/eio/pull/339

aantron commented 1 year ago

This is indeed an awkward part of the API and will need to change. Historically, it became this way because S_IFMT was added later than the other bits. However, I see that this is no longer being used in eio_luv at the moment, so I think it can be delayed, after a maintenance release of Luv.

haesbaert commented 1 year ago

Thank you for looking into this. It's not a pressing matter for us as I ended up just grabing the stat directly through the Unix module. There's also the future of luv/libuv being phased out in EIO in favor of eio_posix + some windows backend, not due to luv, more due to how libuv associates handles with loops which make it cumbersome to support in EIO.