Skip to content

Create a struct similar to std::fs::File for directories #3644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MarkusTieger opened this issue May 22, 2024 · 2 comments
Closed

Create a struct similar to std::fs::File for directories #3644

MarkusTieger opened this issue May 22, 2024 · 2 comments

Comments

@MarkusTieger
Copy link

There is currently no safe way in rust to open a filedescriptor on a directory and using it for reading entries. Currently you always have to open a new filedescriptor using std::fs::read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir>. At least for my understanding, if you need to access the directory multiple times (for example for a directory watcher), this is inefficient.

A solution would be to introduce a new struct called "Dir" or "Directory" with a "read_dir" function, which can be used to access a directory multiple times without opening another filedescriptor. Another solution would be to extend the std::fs::File struct with a "read_dir" function.

@BurntSushi
Copy link
Member

rust-lang/rust#120426

@MarkusTieger
Copy link
Author

Sorry for the duplicate

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

No branches or pull requests

2 participants