Skip to content

Add Eio.Path.of_dir - #919

Merged
talex5 merged 1 commit into
ocaml-multicore:mainfrom
talex5:path-of-dir
Aug 5, 2026
Merged

Add Eio.Path.of_dir#919
talex5 merged 1 commit into
ocaml-multicore:mainfrom
talex5:path-of-dir

Conversation

@talex5

@talex5 talex5 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

This is perhaps slightly clearer than creating a (dir, "") tuple manually, and avoids having to think about whether to use "." or "".

It also opens up the possibility of making Path.t private at some point. The extra variance annotations are just to make testing that easier.

I updated the backends to use it for fs and cwd and made them a bit more similar to each other.

This is perhaps slightly clearer than creating a `(dir, "")` tuple
manually, and avoids having to think about whether to use "." or "".

It also opens up the possibility of making `Path.t` `private` at some
point. The extra variance annotations are just to make testing that
easier.

I updated the backends to use it for `fs` and `cwd` and made them a bit
more similar to each other.
Comment thread lib_eio_posix/fs.ml
let cwd = Eio.Resource.T (Dir.v ~label:"cwd" ~path:"." Cwd, Handler.v)
let dir ~label ~path fd = Eio.Resource.T (Dir.v ~label ~path fd, Handler.v)

let fs = Eio.Path.of_dir (dir ~label:"fs" ~path:"." Fs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of "." in the posix backend and "" in the Linux one probably deserves a comment to explain it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it actually matters (the tests pass either way). The only thing that uses it is generating native paths, and native_internal checks for "." and treats it as "" anyway. But it was like that before - it's not part of this change. I'll make a separate PR cleaning it up.

@talex5
talex5 merged commit af471df into ocaml-multicore:main Aug 5, 2026
5 checks passed
@talex5
talex5 deleted the path-of-dir branch August 5, 2026 17:19
@talex5 talex5 mentioned this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants