Add Eio.Path.of_dir - #919
Merged
Merged
Conversation
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.
avsm
approved these changes
Aug 5, 2026
| 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) |
Contributor
There was a problem hiding this comment.
The use of "." in the posix backend and "" in the Linux one probably deserves a comment to explain it.
Collaborator
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tprivateat some point. The extra variance annotations are just to make testing that easier.I updated the backends to use it for
fsandcwdand made them a bit more similar to each other.