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

A consistent definition for paths + EmbeddedFS quirk #24

Closed
Technohacker opened this issue Feb 25, 2022 · 2 comments
Closed

A consistent definition for paths + EmbeddedFS quirk #24

Technohacker opened this issue Feb 25, 2022 · 2 comments

Comments

@Technohacker
Copy link
Contributor

Technohacker commented Feb 25, 2022

Hello!
I'm in the process of building an implementation of FileSystem for my own use, where I can mount other VFS implementations under a single root. Having some documentation on the FileSystem trait on the sort of paths that the implementation is expected to support would be a huge boon

A specific situation I am dealing with at the moment is the root folder. EmbeddedFS has a quirk with read_dir where:

  1. On an instance of EmbeddedFS, I can read_dir("/") and have a successful Result from it
  2. After conversion of the EmbeddedFS instance to a VfsPath directly without any join()s, path.read_dir() fails with an Error, saying it cannot read ""

You can test this with:

EmbeddedFS::<RustEmbedRoot>::new().read_dir("/").unwrap().for_each(|x| println!("{}", x.as_str()));

// and

let p: VfsPath = EmbeddedFS::<RustEmbedRoot>::new().into();
p.read_dir().unwrap();

With the current implementation of VfsPath::join, I can't do path.join("/") which is alright, but I'd love to have a consistent definition :)

manuel-woelker added a commit that referenced this issue Feb 27, 2022
@Technohacker
Copy link
Contributor Author

Tested the commit and EmbeddedFS works again, thanks!

I'm not sure if this is a pending change, but I believe this line should be with a starting /?

/// All path parameters are absolute, without a starting '/'.

My implementation receives absolute paths with a starting slash from vfs as of the linked commit, just wanted to know if it was a planned change for later

manuel-woelker added a commit that referenced this issue Mar 1, 2022
@manuel-woelker
Copy link
Owner

Hi, thanks for the test and feedback!

You are totally right, all paths (apart from the root path "") start with a slash, I updated the docs - Good catch, much appreciated!

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