From 61d75021c8a1180d2b591e70c783bd2eb21188bd Mon Sep 17 00:00:00 2001 From: Erik K Date: Thu, 26 May 2022 16:31:27 +0000 Subject: mkdir parent directories when needed, also fixed bug in list(). --- posts.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'posts.c') diff --git a/posts.c b/posts.c index 239f118..04535b9 100644 --- a/posts.c +++ b/posts.c @@ -1,4 +1,5 @@ -#include +#include +#include #include #include @@ -71,7 +72,12 @@ href=\"mailto:erikk@previousplan.org\">erikk@previousplan.org \ qsort(doc, ndoc, sizeof(*doc), (int (*)(const void *, const void *))creatcompar); - outf = xfopen(kpostsexport, "w"); + if (!mkparentdirs(kpostsexport)) + return; + if ((outf = fopen(kpostsexport, "w")) == NULL) { + fprintf(stderr, "%s: %s\n", kpostsexport, strerror(errno)); + return; + } xfputs(header, outf); for (i = 0; i < ndoc; i++) { my_strlcpy(title, doc[i]->title, sizeof(title)); -- cgit v1.2.3