diff options
Diffstat (limited to 'src/Configuration.cpp')
-rw-r--r-- | src/Configuration.cpp | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/Configuration.cpp b/src/Configuration.cpp index a4d71e9..9bb2ac6 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -20,6 +20,37 @@ // IWYU pragma: no_include <algorithm> namespace patchage { +namespace { + +/// Return a vector of filenames in descending order by preference +std::vector<std::string> +get_filenames() +{ + std::vector<std::string> filenames; + const std::string prefix; + + const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); + const char* home = getenv("HOME"); + + // XDG spec + if (xdg_config_home) { + filenames.push_back(std::string(xdg_config_home) + "/patchagerc"); + } else if (home) { + filenames.push_back(std::string(home) + "/.config/patchagerc"); + } + + // Old location + if (home) { + filenames.push_back(std::string(home) + "/.patchagerc"); + } + + // Current directory (bundle or last-ditch effort) + filenames.emplace_back("patchagerc"); + + return filenames; +} + +} // namespace static const char* const port_type_names[Configuration::n_port_types] = {"JACK_AUDIO", "JACK_MIDI", "ALSA_MIDI", "JACK_OSC", "JACK_CV"}; @@ -152,34 +183,6 @@ Configuration::set_module_split(const std::string& name, bool split) } } -/** Return a vector of filenames in descending order by preference. */ -static std::vector<std::string> -get_filenames() -{ - std::vector<std::string> filenames; - const std::string prefix; - - const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); - const char* home = getenv("HOME"); - - // XDG spec - if (xdg_config_home) { - filenames.push_back(std::string(xdg_config_home) + "/patchagerc"); - } else if (home) { - filenames.push_back(std::string(home) + "/.config/patchagerc"); - } - - // Old location - if (home) { - filenames.push_back(std::string(home) + "/.patchagerc"); - } - - // Current directory (bundle or last-ditch effort) - filenames.emplace_back("patchagerc"); - - return filenames; -} - void Configuration::load() { |