Fix config files loading other config files

This commit is contained in:
Linus Dierheimer
2023-01-15 20:03:28 +01:00
parent 14286e8c0f
commit ab7b0571f3
+10 -7
View File
@@ -651,21 +651,24 @@ static void optionParseConfigFile(FFinstance* instance, FFdata* data, const char
//Try to load as a relative path
FFstrbuf absolutePath;
ffStrbufInitA(&absolutePath, 128);
FF_LIST_FOR_EACH(FFstrbuf, path, instance->state.platform.dataDirs)
{
uint32_t pathLength = path->length;
//We need to copy it, because if a config file loads a config file, the value of path must be unchanged
ffStrbufSet(&absolutePath, path);
ffStrbufAppendS(&absolutePath, "fastfetch/presets/");
ffStrbufAppendS(&absolutePath, value);
ffStrbufAppendS(path, "fastfetch/presets/");
ffStrbufAppendS(path, value);
bool success = parseConfigFile(instance, data, path->chars);
ffStrbufSubstrBefore(path, pathLength);
bool success = parseConfigFile(instance, data, absolutePath.chars);
if(success)
return;
}
ffStrbufDestroy(&absolutePath);
//File not found
fprintf(stderr, "Error: couldn't find config: %s\n", value);