Skip to content

Commit

Permalink
AudioGraphConfig: Allow using relative paths within SIGNALFLOW_USER_DIR
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Sep 8, 2024
1 parent d261432 commit 576cc70
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions source/src/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 576cc70

Please sign in to comment.