From 269355a99ced7981d9c24aad290bbf6763559df9 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sat, 27 May 2023 12:07:47 -0700 Subject: [PATCH] Ensure {datadir}/templates exists when making template Example mkdir /tmp/tp tuxpaint --datadir /tmp/tp without this fix, choosing "Template" (make a new templat) from "Open" dialog would result in an error, since `/tmp/tp/templates` did not exist. We now `mkdir()` it. This requires, of course, that the directory specified by `--datadir` _itself_ exists. (We will not attempt to create anything higher up.) --- src/tuxpaint.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 79e266a14..68b3edc20 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -31288,6 +31288,11 @@ static int export_pict(char *fname, int where) int len = (strlen(dir) + 64); char timestamp[16]; + if (!make_directory(DIR_DATA, "templates", "Can't create 'templates' directory in specified datadir")) + { + return(SDL_FALSE); + } + /* Create a unique filename, within that dir */ t = time(NULL); strftime(timestamp, sizeof(timestamp), "%Y%m%d%H%M%S", localtime(&t));