Skip to content
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

icfs-fatfs: provide similar functionality to std::fs #23

Open
paulyoung opened this issue Apr 12, 2022 · 2 comments
Open

icfs-fatfs: provide similar functionality to std::fs #23

paulyoung opened this issue Apr 12, 2022 · 2 comments

Comments

@paulyoung
Copy link
Member

paulyoung commented Apr 12, 2022

Some of the code from the fatfs example could be moved to the crate and adapted to expose functions more like those in std::fs.

For example, the code in mkdir could become something like std::fs::create_dir<P: AsRef<Path>>(path: P) -> Result<()>. We might be able to provide a new platform-specific implementation of DirBuilder, or at least model the implementation on that.

We could also implement create_dir_all and parts of the API that make sense rather than having consumers reimplement the same thing themselves.

@emilniklas
Copy link

What do you think of an API strategy like the log crate? I.e. the icfs crate keeping a global trait object, along with a set_system(sys: impl FileSystem) that sets the global.

Then all std::fs-like functions can be exposed on icfs and implemented once for all filesystem implementations.

The con is potential tiny overhead of dynamic dispatch on trait object, and also overhead of taking locks on a RwLock or whatever.

@paulyoung
Copy link
Member Author

I’m not sure! I appreciate the suggestion and will definitely give it some consideration before working on this 👍

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