diff --git a/classes/Settings.m b/classes/Settings.m index 9afdc2c433dea2d28665cdf3ec6cc080e5eb0919..47da9c6a4783f380eac689dfb3fdaa078d8e4ab8 100644 --- a/classes/Settings.m +++ b/classes/Settings.m @@ -8,8 +8,11 @@ classdef Settings < Config & dynamicprops % Loaded config: - % Loaded data: - % Arguments: -% - configNames: config file names. Accepts shortened version -% e.g: ode -> odeConfig.m +% - configNames: config file names or path. +% Accepts shortened version, e.g: ode -> odeConfig.m +% +% If config name is provided, Settings checks inside the settings +% folder or inside the caller's folder properties(Access = protected) configPath = '' @@ -22,7 +25,7 @@ classdef Settings < Config & dynamicprops arguments (Input, Repeating) configNames char end - + configNames = string(configNames); noConfig = ~endsWith(configNames, ["Config.m", "Config"]); @@ -51,7 +54,12 @@ classdef Settings < Config & dynamicprops outputVariables = struct(); for i = 1:length(configNames) fileName = configNames{i}; - filePath = fullfile(fileparts(mfilename("fullpath")), '..', 'settings'); + filePath = ''; + + if ~isfile(fileName) + filePath = trimPath( ... + fullfile(fileparts(mfilename("fullpath")), '..', 'settings')); + end if ~isfile(fullfile(filePath, fileName)) % Get caller function path callers = dbstack("-completenames"); @@ -61,9 +69,9 @@ classdef Settings < Config & dynamicprops end if ~isfile(fullfile(filePath, fileName)) - error(['File not found inside the settings folder, nor in local folder: %s\n' ... - 'Check that the correct mission is set in your component ' ... - 'and the config file exists'], fileName); + error(['File not found inside the target folder: %s, at\n' ... + '%s\n' ... + 'Check that the config file exists'], fileName, filePath); end variables = [who(); "variables"];