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

TODO: Add method to get DirEntry from a path #16

Open
henrygab opened this issue Sep 26, 2018 · 6 comments
Open

TODO: Add method to get DirEntry from a path #16

henrygab opened this issue Sep 26, 2018 · 6 comments

Comments

@henrygab
Copy link
Contributor

add method for getting DirEntry from a path (possible names: metadata, lookup)

(putting TODO list into issues for easier tracking and referencing in pull requests)

@ischeinkman
Copy link

ischeinkman commented Dec 30, 2018

Would it also be possible to get the DirEntry from an already created File or Dir? So that, for example, one could get the length of a file or its name from the results of a fs.root_dir()?.open_file(path)? call?

@rafalh
Copy link
Owner

rafalh commented Dec 30, 2018

@ischeinkman Well, technically it would be possible to add such API. But after feature from this issue is implemented (Add method to get DirEntry from a path) you could just get DirEntry first and then call to_file on it. So instead of getting DirEntry from File you would be getting File from DirEntry.
Would it work in your specific case? If not why do you need such functionality?

@ischeinkman
Copy link

Right now I'm implementing a C wrapper library that requires me to be able to lookup file info by path and do so while maintaining a File handle's seek position. As far as I am aware, even with the get_file_from_path feature, we would not be able to look up an opened and already seeked file handle via name, correct?

@rafalh
Copy link
Owner

rafalh commented Dec 31, 2018

By get_file_from_path you mean this issue (Add method to get DirEntry from a path)? You will be able to lookup directory entry even if file is opened. If you need accurate information about file size you would have to call flush() on file after modification. I think it would be problematic to convert File to DirEntry because File remembers only SFN (Short File Name) entry and not the LFN ones. File was meant as FileInputOutputStream, not a general structure for accessing file attributes. You can always use both structs at the same time in your library. Size of file can be retrieved by seeking right now but I could add function for getting the size.
If you want to discuss more ideas about API please create a new issue because this one is about adding function for converting path into DirEntry. You can suggest what name is best for such function. I think I'm gonna call it lookup as similar functionality in Linux kernel.

@ethever
Copy link

ethever commented Sep 23, 2023

Hallo, any progress in this pr?

@henrygab
Copy link
Contributor Author

This isn't a PR. This is an issue. It's a feature that may, or may not, be implemented in the future.

This particular feature was embedded inside the code as a TODO. I just pulled it out into its own issue for easier tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants