From 4726e3cb4f1c1fa235015b849be62a189cb30bd7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 19 Jan 2016 22:33:37 +0100 Subject: [PATCH] Cleanups - add more actions to content_ctl --- command_event.c | 8 ++++---- content.c | 20 +++++++++++++++++--- content.h | 26 ++++++-------------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/command_event.c b/command_event.c index 5ad658aa8d..abd1ff5a19 100644 --- a/command_event.c +++ b/command_event.c @@ -459,7 +459,7 @@ static void event_load_auto_state(void) if (!path_file_exists(savestate_name_auto)) return; - ret = load_state(savestate_name_auto); + ret = content_ctl(CONTENT_CTL_LOAD_STATE, (void*)savestate_name_auto); RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto); @@ -612,7 +612,7 @@ static bool event_save_auto_state(void) fill_pathname_noext(savestate_name_auto, global->name.savestate, ".auto", sizeof(savestate_name_auto)); - ret = save_state(savestate_name_auto); + ret = content_ctl(CONTENT_CTL_SAVE_STATE, (void*)savestate_name_auto); RARCH_LOG("Auto save state to \"%s\" %s.\n", savestate_name_auto, ret ? "succeeded" : "failed"); @@ -780,7 +780,7 @@ static void event_save_state(const char *path, { settings_t *settings = config_get_ptr(); - if (!save_state(path)) + if (!content_ctl(CONTENT_CTL_SAVE_STATE, (void*)path)) { snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), @@ -807,7 +807,7 @@ static void event_load_state(const char *path, char *s, size_t len) { settings_t *settings = config_get_ptr(); - if (!load_state(path)) + if (!content_ctl(CONTENT_CTL_LOAD_STATE, (void*)path)) { snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE), diff --git a/content.c b/content.c index facb70ebad..46eba3d249 100644 --- a/content.c +++ b/content.c @@ -153,7 +153,7 @@ error: * * Returns: true if successful, false otherwise. **/ -bool save_state(const char *path) +static bool content_save_state(const char *path) { bool ret = false; void *data = NULL; @@ -192,14 +192,14 @@ bool save_state(const char *path) } /** - * load_state: + * content_load_state: * @path : path that state will be loaded from. * * Load a state from disk to memory. * * Returns: true if successful, false otherwise. **/ -bool load_state(const char *path) +static bool content_load_state(const char *path) { unsigned i; ssize_t size; @@ -770,6 +770,20 @@ bool content_ctl(enum content_ctl_state state, void *data) switch(state) { + case CONTENT_CTL_LOAD_STATE: + { + const char *path = (const char*)data; + if (!path) + return false; + return content_load_state(path); + } + case CONTENT_CTL_SAVE_STATE: + { + const char *path = (const char*)data; + if (!path) + return false; + return content_save_state(path); + } case CONTENT_CTL_INIT: if (content_init_file(temporary_content)) return true; diff --git a/content.h b/content.h index f7692df7c0..fd1434eb5a 100644 --- a/content.h +++ b/content.h @@ -40,32 +40,18 @@ enum content_ctl_state * Returns : true if successful, otherwise false. */ CONTENT_CTL_INIT, + /* Load a state from disk to memory. */ + CONTENT_CTL_LOAD_STATE, + + /* Save a state from memory to disk. */ + CONTENT_CTL_SAVE_STATE, + /* Frees temporary content handle. */ CONTENT_CTL_TEMPORARY_FREE }; /* Handles files related to libretro. */ -/** - * load_state: - * @path : path that state will be loaded from. - * - * Load a state from disk to memory. - * - * Returns: true if successful, false otherwise. - **/ -bool load_state(const char *path); - -/** - * save_state: - * @path : path of saved state that shall be written to. - * - * Save a state from memory to disk. - * - * Returns: true if successful, false otherwise. - **/ -bool save_state(const char *path); - /** * load_ram_file: * @path : path of RAM state that will be loaded from.