From 70be447f74b87c11557d2b5b1463005fddb0495a Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Fri, 6 Nov 2015 12:19:39 -0800 Subject: Menu ROM now pulls real file names from the OS rather than using a fake list --- config.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'config.c') 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; -- cgit v1.2.3