summaryrefslogtreecommitdiffstats
path: root/posts.c
diff options
context:
space:
mode:
authorErik K <erikk@previousplan.org>2022-05-26 16:31:27 +0000
committerErik K <erikk@previousplan.org>2022-05-26 16:31:27 +0000
commit61d75021c8a1180d2b591e70c783bd2eb21188bd (patch)
treee5401f7c66da4b41eb1bc7f01a8e98a38f8ceae8 /posts.c
parent9643e3cb444ee26088be4636ba2b753ac0166156 (diff)
mkdir parent directories when needed, also fixed bug in list().HEADmaster
Diffstat (limited to 'posts.c')
-rw-r--r--posts.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/posts.c b/posts.c
index 239f118..04535b9 100644
--- a/posts.c
+++ b/posts.c
@@ -1,4 +1,5 @@
-#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -71,7 +72,12 @@ href=\"mailto:erikk@previousplan.org\">erikk@previousplan.org</a> \
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));