diff --git a/CHANGELOG.md b/CHANGELOG.md index eafb2f57f5..ebd82da00d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Bugfixes: * Fix segfault in CPU module when running in aarch64 machine without `lscpu` installed (CPU, Linux) * Don't use `login` as terminal process (Terminal, Linux) * Silence warnings when building in 32bit machines. +* Create sub folders when writing config file (#690) # 2.6.0 diff --git a/src/fastfetch.c b/src/fastfetch.c index f60ae9ad35..68bcea67f3 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -7,6 +7,7 @@ #include "common/jsonconfig.h" #include "detection/version/version.h" #include "util/stringUtils.h" +#include "util/mallocHelper.h" #include "logo/logo.h" #include "fastfetch_datatext.h" @@ -831,7 +832,14 @@ static void writeConfigFile(FFdata* data, const FFstrbuf* filename) yyjson_mut_write_fp(stdout, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL); else { - if (yyjson_mut_write_file(filename->chars, doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, NULL, NULL)) + size_t len; + FF_AUTO_FREE const char* str = yyjson_mut_write(doc, YYJSON_WRITE_INF_AND_NAN_AS_NULL | YYJSON_WRITE_PRETTY_TWO_SPACES, &len); + if (!str) + { + printf("Error: failed to generate config file\n"); + exit(1); + } + if (ffWriteFileData(filename->chars, len, str)) printf("The generated config file has been written in `%s`\n", filename->chars); else {