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

Support for XDG variables with multiple paths #9

Open
robinkrahl opened this issue Aug 2, 2020 · 3 comments · May be fixed by #12
Open

Support for XDG variables with multiple paths #9

robinkrahl opened this issue Aug 2, 2020 · 3 comments · May be fixed by #12

Comments

@robinkrahl
Copy link
Contributor

Issue for app_dirs

The XDG Base Directory Specification allows multiple values for the XDG_DATA_DIRS and XDG_CONFIG_DIRS variables that store the location of the shared data. Implementers of the specification should look for configuration files in all of the specified directories.

app_dirs2 currently always uses the first entry of the variables and ignores the rest. To make app_dirs2 compliant with the specification, you would have to make two changes:

  1. app_dirs2 should at least check whether an application directory already exists in one of the specified directories. This would only require changes to the internal lookup implementations and would not break the public API.
  2. app_dirs2 should make it possible to query all available data directories.
    1. This could be done by changing the return type of the existing functions. But this would break the public API and would make it harder to use the crate with single directories, i. e. on all non-XDG platforms and for all data types but SharedConfig and SharedData.
    2. Alternatively, you could add new functions to query multiple directories, e. g. get_data_roots, get_app_roots and get_app_dirs.

What do you think? Would you accept a PR that implements 1 + 2.ii.?

@robinkrahl robinkrahl changed the title Support for Support for XDG variables with multiple paths Aug 2, 2020
@kornelski
Copy link
Contributor

Yes, 1 + 2.ii. sounds great.

@robinkrahl
Copy link
Contributor Author

Okay, I’m working on a PR.

The implementation functions and the new multi-path getter functions will return a Vec<PathBuf> with at least one element. Should I use vec1 to express this invariant using the type system or is it enough to add it to the documentation?

@kornelski
Copy link
Contributor

vec1 is an overkill. Regular vec should be enough.

robinkrahl added a commit to robinkrahl/app_dirs2 that referenced this issue Aug 5, 2020
Previously, the get_app_dir function defined by the implementations
returned a single PathBuf.  But as discussed in issue 9 [0], there might
be multiple base directories.  For example, the unix implementation uses
the XDG Base Directory Specification which supports multiple shared
config and data directories.

[0] app-dirs-rs#9

With this patch, we rename the internal get_app_dir function to
get_app_dirs and change its return type to Vec<PathBuf> to enable
handling multiple app directories.
@robinkrahl robinkrahl linked a pull request Aug 5, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants