diff options
author | Linus Heckemann <git@sphalerite.org> | 2018-10-25T11·00+0200 |
---|---|---|
committer | Linus Heckemann <git@sphalerite.org> | 2018-10-31T08·24+0100 |
commit | f3b8173a93a3571046ef6765afe1a15efc1e0de6 (patch) | |
tree | b2b5c865eae201be54e908b45ee4a5ed5d97394c /src/libutil/util.cc | |
parent | 7a9ac91a43e1e05e9df9d1b9b4a2cf322d62bb1c (diff) |
config: use all of XDG_CONFIG_DIRS
Previously, config would only be read from XDG_CONFIG_HOME. This change allows reading config from additional directories, which enables e.g. per-project binary caches or chroot stores with the help of direnv.
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r-- | src/libutil/util.cc | 9 |
1 files changed, 9 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() { |