From 576cc700ddfe52f2ff8e9bab4a9aa4581e6a142b Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Sun, 8 Sep 2024 19:58:50 +0200 Subject: [PATCH] AudioGraphConfig: Allow using relative paths within SIGNALFLOW_USER_DIR --- source/src/core/config.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/source/src/core/config.cpp b/source/src/core/config.cpp index 9ec10e00..a3167e8b 100644 --- a/source/src/core/config.cpp +++ b/source/src/core/config.cpp @@ -73,8 +73,10 @@ AudioGraphConfig::AudioGraphConfig() std::string config_path = SIGNALFLOW_USER_DIR + "/config"; std::ifstream input(config_path); - // Don't throw an error if the user config file does not exist, - // just continue silently. + /*-------------------------------------------------------------------------------- + * Don't throw an error if the user config file does not exist, + * just continue silently. + *--------------------------------------------------------------------------------*/ if (input.good()) { parse_file(input); @@ -86,9 +88,17 @@ AudioGraphConfig::AudioGraphConfig() AudioGraphConfig::AudioGraphConfig(std::string config_path) { std::ifstream input(config_path); + /*-------------------------------------------------------------------------------- + * For user-specified paths, try opening the unqualified path initially, + * then relative to the user dir. + *--------------------------------------------------------------------------------*/ if (!input.good()) { - throw std::runtime_error("Config path could not be read: " + config_path); + input.open(SIGNALFLOW_USER_DIR + "/" + config_path); + if (!input.good()) + { + throw std::runtime_error("Config path could not be found: " + config_path); + } } parse_file(input);