changeset 1540:e94cff9cb625 nuklear_ui

Make sure config directory exists before trying to save config file
author Michael Pavone <pavone@retrodev.com>
date Sun, 25 Mar 2018 12:00:29 -0700
parents 5b1157eb189d
children f8ef74e7c800 112c7af033ff
files config.c util.c util.h
diffstat 3 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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)) {
--- 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