From 6195deb1888530d3546e9f540693c6f8287da6a2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:31:56 +0200 Subject: [PATCH] De-ioctl-ify content functions --- command_event.c | 12 ++++++------ content.c | 32 ++++++-------------------------- content.h | 21 ++++++++++++--------- 3 files changed, 24 insertions(+), 41 deletions(-) diff --git a/command_event.c b/command_event.c index 69484e48ac..9dedb199db 100644 --- a/command_event.c +++ b/command_event.c @@ -448,7 +448,7 @@ static bool event_load_save_files(void) ram.path = global->savefiles->elems[i].data; ram.type = global->savefiles->elems[i].attr.i; - content_ctl(CONTENT_CTL_LOAD_RAM_FILE, &ram); + content_load_ram_file(&ram); } return true; @@ -481,7 +481,7 @@ static void event_load_auto_state(void) if (!path_file_exists(savestate_name_auto)) return; - ret = content_ctl(CONTENT_CTL_LOAD_STATE, (void*)savestate_name_auto); + ret = content_load_state(savestate_name_auto); RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto); @@ -643,7 +643,7 @@ static bool event_save_auto_state(void) fill_pathname_noext(savestate_name_auto, global->name.savestate, ".auto", sizeof(savestate_name_auto)); - ret = content_ctl(CONTENT_CTL_SAVE_STATE, (void*)savestate_name_auto); + ret = content_save_state((const char*)savestate_name_auto); RARCH_LOG("Auto save state to \"%s\" %s.\n", savestate_name_auto, ret ? "succeeded" : "failed"); @@ -814,7 +814,7 @@ static void event_save_state(const char *path, { settings_t *settings = config_get_ptr(); - if (!content_ctl(CONTENT_CTL_SAVE_STATE, (void*)path)) + if (!content_save_state(path)) { snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), @@ -842,7 +842,7 @@ static void event_load_state(const char *path, char *s, size_t len) { settings_t *settings = config_get_ptr(); - if (!content_ctl(CONTENT_CTL_LOAD_STATE, (void*)path)) + if (!content_load_state(path)) { snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE), @@ -1497,7 +1497,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) ram.type, msg_hash_to_str(MSG_TO), ram.path); - content_ctl(CONTENT_CTL_SAVE_RAM_FILE, &ram); + content_save_ram_file(&ram); } } return true; diff --git a/content.c b/content.c index 6094b72425..71ff80c124 100644 --- a/content.c +++ b/content.c @@ -1016,7 +1016,7 @@ static bool dump_to_file_desperate(const void *data, * * Returns: true if successful, false otherwise. **/ -static bool content_save_state(const char *path) +bool content_save_state(const char *path) { retro_ctx_serialize_info_t serial_info; retro_ctx_size_info_t info; @@ -1068,7 +1068,7 @@ static bool content_save_state(const char *path) * * Returns: true if successful, false otherwise. **/ -static bool content_load_state(const char *path) +bool content_load_state(const char *path) { unsigned i; ssize_t size; @@ -1181,18 +1181,17 @@ error: } /** - * load_ram_file: + * content_load_ram_file: * @path : path of RAM state that will be loaded from. * @type : type of memory * * Load a RAM state from disk to memory. */ -static bool load_ram_file(void *data) +bool content_load_ram_file(ram_type_t *ram) { ssize_t rc; retro_ctx_memory_info_t mem_info; void *buf = NULL; - ram_type_t *ram = (ram_type_t*)data; if (!ram) return false; @@ -1229,14 +1228,14 @@ static bool load_ram_file(void *data) } /** - * save_ram_file: + * content_save_ram_file: * @path : path of RAM state that shall be written to. * @type : type of memory * * Save a RAM state from memory to disk. * */ -static bool save_ram_file(ram_type_t *ram) +bool content_save_ram_file(ram_type_t *ram) { retro_ctx_memory_info_t mem_info; @@ -1702,13 +1701,8 @@ static bool content_file_free(struct string_list *temporary_content) bool content_ctl(enum content_ctl_state state, void *data) { - switch(state) { - case CONTENT_CTL_LOAD_RAM_FILE: - return load_ram_file(data); - case CONTENT_CTL_SAVE_RAM_FILE: - return save_ram_file((ram_type_t*)data); case CONTENT_CTL_DOES_NOT_NEED_CONTENT: return core_does_not_need_content; case CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT: @@ -1725,20 +1719,6 @@ bool content_ctl(enum content_ctl_state state, void *data) *content_crc_ptr = &content_crc; } break; - 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_IS_INITED: return content_is_inited; case CONTENT_CTL_DEINIT: diff --git a/content.h b/content.h index e1088acac4..8765df2a50 100644 --- a/content.h +++ b/content.h @@ -55,17 +55,8 @@ enum content_ctl_state CONTENT_CTL_GET_CRC, - /* Load a RAM state from disk to memory. */ - CONTENT_CTL_LOAD_RAM_FILE, - /* Save a RAM state from memory to disk. */ - CONTENT_CTL_SAVE_RAM_FILE, - /* 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, @@ -100,6 +91,18 @@ typedef struct content_ctx_info void content_push_to_history_playlist(bool do_push, const char *path, void *data); +/* Load a RAM state from disk to memory. */ +bool content_load_ram_file(ram_type_t *ram); + +/* Save a RAM state from memory to disk. */ +bool content_save_ram_file(ram_type_t *ram); + +/* Load a state from disk to memory. */ +bool content_load_state(const char *path); + +/* Save a state from memory to disk. */ +bool content_save_state(const char *path); + bool content_ctl(enum content_ctl_state state, void *data); #ifdef __cplusplus