diff --git a/command_event.c b/command_event.c index 88d37ce6f7..51becca1bc 100644 --- a/command_event.c +++ b/command_event.c @@ -1482,7 +1482,7 @@ bool event_command(enum event_command cmd) input_driver_ctl(RARCH_INPUT_CTL_REMOTE_INIT, NULL); break; case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: - content_temporary_free(); + content_ctl(CONTENT_CTL_TEMPORARY_FREE, NULL); break; case EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT: if (!global) diff --git a/content.c b/content.c index 52281e34f7..a7af776c26 100644 --- a/content.c +++ b/content.c @@ -750,34 +750,39 @@ bool init_content_file(void) error: if (content) string_list_free(content); - content_temporary_free(); + content_ctl(CONTENT_CTL_TEMPORARY_FREE, NULL); return false; } -/** - * content_free_temporary: - * - * Frees temporary content handle. - **/ -void content_temporary_free(void) +bool content_ctl(enum content_ctl_state state, void *data) { unsigned i; - if (!temporary_content) - return; - - for (i = 0; i < temporary_content->size; i++) + switch(state) { - const char *path = temporary_content->elems[i].data; + case CONTENT_CTL_TEMPORARY_FREE: + if (!temporary_content) + return false; - RARCH_LOG("%s: %s.\n", - msg_hash_to_str(MSG_REMOVING_TEMPORARY_CONTENT_FILE), path); - if (remove(path) < 0) - RARCH_ERR("%s: %s.\n", - msg_hash_to_str(MSG_FAILED_TO_REMOVE_TEMPORARY_FILE), - path); + for (i = 0; i < temporary_content->size; i++) + { + const char *path = temporary_content->elems[i].data; + + RARCH_LOG("%s: %s.\n", + msg_hash_to_str(MSG_REMOVING_TEMPORARY_CONTENT_FILE), path); + if (remove(path) < 0) + RARCH_ERR("%s: %s.\n", + msg_hash_to_str(MSG_FAILED_TO_REMOVE_TEMPORARY_FILE), + path); + } + string_list_free(temporary_content); + + temporary_content = NULL; + break; + case CONTENT_CTL_NONE: + default: + break; } - string_list_free(temporary_content); - temporary_content = NULL; + return true; } diff --git a/content.h b/content.h index a65a7db181..da0e587f55 100644 --- a/content.h +++ b/content.h @@ -27,6 +27,14 @@ extern "C" { #endif +enum content_ctl_state +{ + CONTENT_CTL_NONE = 0, + + /* Frees temporary content handle. */ + CONTENT_CTL_TEMPORARY_FREE +}; + /* Handles files related to libretro. */ /** @@ -83,7 +91,7 @@ void save_ram_file(const char *path, int type); **/ bool init_content_file(void); -void content_temporary_free(void); +bool content_ctl(enum content_ctl_state state, void *data); #ifdef __cplusplus }