# HG changeset patch # User Michael Pavone # Date 1522004429 25200 # Node ID e94cff9cb625a92aaad29d2c22ad2eefdafc630b # Parent 5b1157eb189d2446647f5b01625bfa4e8aff3b11 Make sure config directory exists before trying to save config file diff -r 5b1157eb189d -r e94cff9cb625 config.c --- a/config.c Sun Mar 25 10:49:19 2018 -0700 +++ b/config.c Sun Mar 25 12:00:29 2018 -0700 @@ -250,6 +250,7 @@ if (!confdir) { fatal_error("Failed to locate config file directory\n"); } + ensure_dir_exists(confdir); char *confpath = path_append(confdir, "blastem.cfg"); if (!serialize_config_file(config, confpath)) { fatal_error("Failed to write config to %s\n", confpath); diff -r 5b1157eb189d -r e94cff9cb625 util.c --- a/util.c Sun Mar 25 10:49:19 2018 -0700 +++ b/util.c Sun Mar 25 12:00:29 2018 -0700 @@ -549,7 +549,7 @@ return (time_t)wintime; } -int ensure_dir_exists(char *path) +int ensure_dir_exists(const char *path) { if (CreateDirectory(path, NULL)) { return 1; @@ -703,7 +703,7 @@ #endif } -int ensure_dir_exists(char *path) +int ensure_dir_exists(const char *path) { struct stat st; if (stat(path, &st)) { diff -r 5b1157eb189d -r e94cff9cb625 util.h --- a/util.h Sun Mar 25 10:49:19 2018 -0700 +++ b/util.h Sun Mar 25 12:00:29 2018 -0700 @@ -71,7 +71,7 @@ //Gets the modification time of a file time_t get_modification_time(char *path); //Recusrively creates a directory if it does not exist -int ensure_dir_exists(char *path); +int ensure_dir_exists(const char *path); //Returns the contents of a symlink in a newly allocated string char * readlink_alloc(char * path); //Prints an error message to stderr and to a message box if not in headless mode and then exits