More graceful error handling.

This commit is contained in:
Themaister 2012-01-28 15:47:02 +01:00
parent bedd5a691b
commit e8b2cde4cf
3 changed files with 16 additions and 8 deletions

View File

@ -374,10 +374,10 @@ struct global
jmp_buf error_sjlj_context; jmp_buf error_sjlj_context;
}; };
void parse_config(void); void config_load(void);
void config_set_defaults(void); void config_set_defaults(void);
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
void config_load_file(const char *path); bool config_load_file(const char *path);
#endif #endif
void ssnes_main_clear_state(void); void ssnes_main_clear_state(void);

View File

@ -225,7 +225,7 @@ void config_set_defaults(void)
static void parse_config_file(void); static void parse_config_file(void);
#endif #endif
void parse_config(void) void config_load(void)
{ {
#ifdef SSNES_CONSOLE #ifdef SSNES_CONSOLE
if (!g_console.block_config_read) if (!g_console.block_config_read)
@ -315,13 +315,20 @@ static config_file_t *open_default_config_file(void)
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
static void parse_config_file(void) static void parse_config_file(void)
{ {
bool ret;
if (*g_extern.config_path) if (*g_extern.config_path)
config_load_file(g_extern.config_path); ret = config_load_file(g_extern.config_path);
else else
config_load_file(NULL); ret = config_load_file(NULL);
if (!ret)
{
SSNES_ERR("Couldn't find config at path: \"%s\"\n", g_extern.config_path);
ssnes_fail(1, "parse_config_file()");
}
} }
void config_load_file(const char *path) bool config_load_file(const char *path)
{ {
config_file_t *conf = NULL; config_file_t *conf = NULL;
@ -338,7 +345,7 @@ void config_load_file(const char *path)
conf = open_default_config_file(); conf = open_default_config_file();
if (conf == NULL) if (conf == NULL)
return; return true;
if (g_extern.verbose) if (g_extern.verbose)
{ {
@ -496,6 +503,7 @@ void config_load_file(const char *path)
read_keybinds(conf); read_keybinds(conf);
config_file_free(conf); config_file_free(conf);
return true;
} }
struct bind_map struct bind_map

View File

@ -2097,7 +2097,7 @@ int ssnes_main_init(int argc, char *argv[])
fprintf(stderr, "=================================================\n"); fprintf(stderr, "=================================================\n");
} }
parse_config(); config_load();
init_libsnes_sym(); init_libsnes_sym();
fill_title_buf(); fill_title_buf();