-
Notifications
You must be signed in to change notification settings - Fork 540
Add functions to return standard directories #1822
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
Conversation
Would it be better to use |
I think it would be better to keep names consistent with what they are on
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks so much for the docs and tests, a lot of PRs miss those. See review for comments.
b591084
to
0e132e4
Compare
Add the following builtin functions: - `cache_directory()` - `config_directory()` - `config_local_directory()` - `data_directory()` - `data_local_directory()` - `executable_directory()` - `home_directory()` These use the `dirs` crate to return XDG-compliant paths, or the system defaults. Fixes: casey#1820
ddfb64a
to
5910eb9
Compare
I see you changed this to return an error if the directory is not found (thanks for the updates!). Would it be better to make these accept either 0 or 1 argument, so a fallback can be provided if not available? |
Or looks like it's ready to merge. If the above sounds reasonable, I can submit a followup PR :) |
Nice! I tweaked the readme a little, and changed the functions to return an error if the directory isn't found. Also, for some reason, on my mac the executable directory wasn't found, so I modified the test to handle this error. |
Whoops, I just noticed this comment. If people want it, I think it would be fine to modify these functions to accept a fallback which is returned if the directory isn't found. We could either wait and see if anyone complains, or if you feel like it, and do it in a follow up PR. |
Sounds great. Thanks! |
Add the following builtin functions:
cache_directory()
config_directory()
config_local_directory()
data_directory()
data_local_directory()
executable_directory()
home_directory()
These use the
dirs
crate to return XDG-compliant paths, or the system defaults.Fixes: #1820