luv icon indicating copy to clipboard operation
luv copied to clipboard

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

Open haesbaert opened this issue 3 years ago • 2 comments

mode is a Mode.numeric

There is no good way to get the file type, normally you would AND with S_IFMT 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

haesbaert avatar Oct 18 '22 07:10 haesbaert

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.

aantron avatar Apr 07 '23 05:04 aantron

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.

haesbaert avatar Apr 07 '23 08:04 haesbaert