File: utils.cpp

package info (click to toggle)
dnf5 5.4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,960 kB
  • sloc: cpp: 94,312; python: 3,370; xml: 1,073; ruby: 600; sql: 250; ansic: 232; sh: 104; perl: 62; makefile: 30
file content (41 lines) | stat: -rw-r--r-- 1,616 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Contributors to the DNF5 project.
// SPDX-License-Identifier: LGPL-2.1-or-later

#include "libdnf5/plugin/utils.hpp"

#include "libdnf5/base/base.hpp"

namespace libdnf5::plugin {

std::vector<std::filesystem::path> get_config_dirs(const Base & base) {
    std::vector<std::filesystem::path> dirs;
    const auto & config = base.get_config();

// Save the current warning state
#pragma GCC diagnostic push
// Ignore the warning about deprecated declarations
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

    const char * const env_plugins_config_dirs = std::getenv("LIBDNF_PLUGINS_CONFIG_DIR");
    if (env_plugins_config_dirs && config.get_plugin_conf_dir_option().get_priority() < Option::Priority::COMMANDLINE &&
        config.get_pluginconfpath_option().get_priority() < Option::Priority::COMMANDLINE) {
        OptionStringList env_opt{std::string(env_plugins_config_dirs)};
        const auto & env_value = env_opt.get_value();
        dirs = {env_value.begin(), env_value.end()};
    } else if (
        config.get_plugin_conf_dir_option().get_priority() >= config.get_pluginconfpath_option().get_priority()) {
        const auto & conf_value = config.get_plugin_conf_dir_option().get_value();
        dirs = {conf_value.begin(), conf_value.end()};
    } else {
        OptionStringList conf_opt{config.get_pluginconfpath_option().get_value()};
        const auto & conf_value = conf_opt.get_value();
        dirs = {conf_value.begin(), conf_value.end()};
    }

    return dirs;
}

// Restore the previous warning state
#pragma GCC diagnostic pop

}  // namespace libdnf5::plugin