summaryrefslogtreecommitdiff
path: root/src/cfg.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-10-07 21:46:03 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-10-19 00:13:47 +0200
commit3a002fb9c23fc9a6384bc1b30a8e364924bb574e (patch)
tree7cfb59964bc20bbb14d157426b2aad4481deb90d /src/cfg.cc
parent62a4abb9bf6551417130c3c6f9bba147930895ef (diff)
cfg: Make load less magic
Don't try to guess from name, instead, have one method for only loading one config from a file (that might be relative) and loading a config from config dirs using a name (that might contain slash).
Diffstat (limited to 'src/cfg.cc')
-rw-r--r--src/cfg.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/cfg.cc b/src/cfg.cc
index 0196bde..b65246f 100644
--- a/src/cfg.cc
+++ b/src/cfg.cc
@@ -182,16 +182,18 @@ std::optional<bool> Config::get_bool(std::string_view name) const {
return std::nullopt;
}
-std::unique_ptr<Config> Config::load(std::string_view name,
- std::vector<std::string>& errors) {
- if (name.empty() || name.front() == '/') {
- auto ret = std::make_unique<ConfigSingleImpl>();
- ret->load(name, errors);
- return ret;
- }
+std::unique_ptr<Config> load_all(std::string_view name,
+ std::vector<std::string>& errors) {
auto ret = std::make_unique<ConfigXdgImpl>();
ret->load(name, errors);
return ret;
}
+std::unique_ptr<Config> load_one(std::filesystem::path const& path,
+ std::vector<std::string>& errors) {
+ auto ret = std::make_unique<ConfigSingleImpl>();
+ ret->load(path, errors);
+ return ret;
+}
+
} // namespace cfg