summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2018-03-25 12:00:29 -0700
committerMichael Pavone <pavone@retrodev.com>2018-03-25 12:00:29 -0700
commitb6feecb6c12566e9ea826cb67701008f9e423eea (patch)
treea06db423e81d53aee66cfa0b0ca366bd57d71dc8
parent560c8198c006c1d2eddd61329c2657160c144835 (diff)
Make sure config directory exists before trying to save config file
--HG-- branch : nuklear_ui
-rw-r--r--config.c1
-rw-r--r--util.c4
-rw-r--r--util.h2
3 files changed, 4 insertions, 3 deletions
diff --git a/config.c b/config.c
index 71a31f4..14cf5b8 100644
--- a/config.c
+++ b/config.c
@@ -250,6 +250,7 @@ void persist_config(tern_node *config)
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 --git a/util.c b/util.c
index ffd970a..975932a 100644
--- a/util.c
+++ b/util.c
@@ -549,7 +549,7 @@ time_t get_modification_time(char *path)
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 @@ time_t get_modification_time(char *path)
#endif
}
-int ensure_dir_exists(char *path)
+int ensure_dir_exists(const char *path)
{
struct stat st;
if (stat(path, &st)) {
diff --git a/util.h b/util.h
index 53e9929..c846ac5 100644
--- a/util.h
+++ b/util.h
@@ -71,7 +71,7 @@ void sort_dir_list(dir_entry *list, size_t num_entries);
//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