-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add function PathExt::removable
#3
Comments
Sorry, you return fn removable(path: AsRef<Path>) -> Result<bool> {
path.as_ref().parent().map(|parent| parent.writable()).unwrap_or(false)
} |
@marcospb19 I like the idea. I'm trying to use this library to map desired operations to human readable reasons why they are or aren't possible. For example, instead of simply "may I access path X" telling me that it's not accessible, I want it to tell me it's because the path does't exist and that's because it's parent directory doesn't exist (etc.). The goal would be to eventually hook into something like https://docs.rs/fs-err/latest/fs_err/ and give really detailed error messages (behind a feature flag) so when a file operation fails it gives you enough context around the state of the disk to know how to fix it. So I've also need to map a similar set of logic that you've described here for deletion and I had question on this, what do you do for when the user asks if they can remove the root path? It has no parent. It might be unwise to delete it, but I think it's technically possible (i've not tried for obvious reasons). Is that your understanding or would something prevent it? |
@schneems I really like the
In the code snippets I wrote |
In Unix, a file is removable if you have write access to the parent directory.
So you can write something like:
Not sure about Windows tho, what do you think?
The text was updated successfully, but these errors were encountered: