commit a5eae7ea6b35f7b2540fefdf4613a86916f0a0b0
parent 4b7fba261a70bd37e160a7304d454c72c1f75b69
Author: Eyal Sawady <ecs@d2evs.net>
Date: Tue, 29 Sep 2020 01:45:40 -0400
gmnlm: open_bookmarks: call mkdirs
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/gmnlm.c b/src/gmnlm.c
@@ -188,6 +188,15 @@ open_bookmarks(struct browser *browser)
char *path_fmt = get_data_pathfmt();
static char path[PATH_MAX+1];
snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi");
+ if (mkdirs(dirname(path), 0755) != 0) {
+ snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi");
+ free(path_fmt);
+ fprintf(stderr, "Error creating directory %s: %s\n",
+ dirname(path), strerror(errno));
+ return;
+ }
+
+ snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi");
free(path_fmt);
struct stat buf;