summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-11-06 12:19:39 -0800
committerMichael Pavone <pavone@retrodev.com>2015-11-06 12:19:39 -0800
commit70be447f74b87c11557d2b5b1463005fddb0495a (patch)
tree9c871702bd0b40fd1ecb05bcb27dd824f9eb8c48 /config.c
parent60f60cd2c5236b0ba5654174c5faeb4a2d218fc9 (diff)
Menu ROM now pulls real file names from the OS rather than using a fake list
Diffstat (limited to 'config.c')
-rw-r--r--config.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/config.c b/config.c
index fa1d6cb..a4187d5 100644
--- a/config.c
+++ b/config.c
@@ -43,7 +43,7 @@ tern_node * parse_config_int(char **state, int started, int *line)
config_data = started ? NULL : *state;
while ((curline = strtok_r(config_data, "\n", state)))
{
-
+
config_data = NULL;
curline = strip_ws(curline);
int len = strlen(curline);
@@ -61,7 +61,7 @@ tern_node * parse_config_int(char **state, int started, int *line)
}
fatal_error("unexpected } on line %d\n", *line);
}
-
+
char * end = curline + len - 1;
if (*end == '{') {
*end = 0;
@@ -128,7 +128,7 @@ tern_node * parse_config_file_assets(char *config_path)
if (!config_size) {
goto config_empty;
}
-
+
char * config_data = malloc(config_size+1);
if (SDL_RWread(rw, config_data, 1, config_size) != config_size) {
goto config_read_fail;
@@ -152,12 +152,12 @@ tern_node * load_config()
if (ret) {
return ret;
}
-
+
ret = parse_config_file_assets("default.cfg");
if (ret) {
return ret;
}
-
+
fatal_error("Failed to find a config file in internal storage or in the blastem APK\n");
//this will never get reached, but the compiler doesn't know that. Let's make it happy
return NULL;
@@ -169,25 +169,26 @@ tern_node * load_config()
{
char * exe_dir;
char * home = get_home_dir();
- if (home) {
+ tern_node *ret;
+ if (home) {
char * path = alloc_concat(home, "/.config/blastem/blastem.cfg");
- tern_node * ret = parse_config_file(path);
+ ret = parse_config_file(path);
free(path);
if (ret) {
return ret;
}
}
-
+
exe_dir = get_exe_dir();
- if (exe_dir) {
- path = alloc_concat(exe_dir, "/default.cfg");
+ if (exe_dir) {
+ char *path = alloc_concat(exe_dir, "/default.cfg");
ret = parse_config_file(path);
free(path);
if (ret) {
return ret;
}
}
-
+
fatal_error("Failed to find a config file in ~/.config/blastem/blastem.cfg or in the blastem executable directory\n");
//this will never get reached, but the compiler doesn't know that. Let's make it happy
return NULL;