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.)
This commit is contained in:
Bill Kendrick 2023-05-27 12:07:47 -07:00
parent c359216180
commit 269355a99c

View file

@ -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));