diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-10-31T11·37+0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-31T11·37+0100 |
commit | fb35aaa42295940ca8dbfef17b081729636f9775 (patch) | |
tree | 1b616ccaa8c3608970f23a0885199c426ed43ff6 /src/libutil | |
parent | 38d76d6d78e691c5ede8b929cf41ffe849349a8e (diff) | |
parent | f3b8173a93a3571046ef6765afe1a15efc1e0de6 (diff) |
Merge pull request #2501 from mayflower/xdg_config_dirs
config: use all of XDG_CONFIG_DIRS
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/util.cc | 9 | ||||
-rw-r--r-- | src/libutil/util.hh | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 03f0be705c1d..259eaf0a0dd3 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -496,6 +496,15 @@ Path getConfigDir() return configDir; } +std::vector<Path> getConfigDirs() +{ + Path configHome = getConfigDir(); + string configDirs = getEnv("XDG_CONFIG_DIRS"); + std::vector<Path> result = tokenizeString<std::vector<string>>(configDirs, ":"); + result.insert(result.begin(), configHome); + return result; +} + Path getDataDir() { diff --git a/src/libutil/util.hh b/src/libutil/util.hh index fc25d27758c7..bda87bee433e 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -131,6 +131,9 @@ Path getCacheDir(); /* Return $XDG_CONFIG_HOME or $HOME/.config. */ Path getConfigDir(); +/* Return the directories to search for user configuration files */ +std::vector<Path> getConfigDirs(); + /* Return $XDG_DATA_HOME or $HOME/.local/share. */ Path getDataDir(); |