mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
content.c - cleanups
This commit is contained in:
parent
d818578076
commit
c015711090
55
content.c
55
content.c
@ -1226,6 +1226,9 @@ static bool save_ram_file(ram_type_t *ram)
|
|||||||
{
|
{
|
||||||
retro_ctx_memory_info_t mem_info;
|
retro_ctx_memory_info_t mem_info;
|
||||||
|
|
||||||
|
if (!ram)
|
||||||
|
return false;
|
||||||
|
|
||||||
mem_info.id = ram->type;
|
mem_info.id = ram->type;
|
||||||
|
|
||||||
core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info);
|
core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info);
|
||||||
@ -1611,7 +1614,7 @@ static bool init_content_file_set_attribs(
|
|||||||
*
|
*
|
||||||
* Returns : true if successful, otherwise false.
|
* Returns : true if successful, otherwise false.
|
||||||
**/
|
**/
|
||||||
static bool content_init_file(struct string_list *temporary_content)
|
static bool content_file_init(struct string_list *temporary_content)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
struct retro_game_info *info = NULL;
|
struct retro_game_info *info = NULL;
|
||||||
@ -1660,6 +1663,29 @@ error:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool content_file_free(struct string_list *temporary_content)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
if (!temporary_content)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool content_ctl(enum content_ctl_state state, void *data)
|
bool content_ctl(enum content_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -1674,13 +1700,7 @@ bool content_ctl(enum content_ctl_state state, void *data)
|
|||||||
case CONTENT_CTL_LOAD_RAM_FILE:
|
case CONTENT_CTL_LOAD_RAM_FILE:
|
||||||
return load_ram_file(data);
|
return load_ram_file(data);
|
||||||
case CONTENT_CTL_SAVE_RAM_FILE:
|
case CONTENT_CTL_SAVE_RAM_FILE:
|
||||||
{
|
return save_ram_file((ram_type_t*)data);
|
||||||
ram_type_t *ram = (ram_type_t*)data;
|
|
||||||
if (!ram)
|
|
||||||
return false;
|
|
||||||
save_ram_file(ram);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CONTENT_CTL_DOES_NOT_NEED_CONTENT:
|
case CONTENT_CTL_DOES_NOT_NEED_CONTENT:
|
||||||
return core_does_not_need_content;
|
return core_does_not_need_content;
|
||||||
case CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT:
|
case CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT:
|
||||||
@ -1724,7 +1744,7 @@ bool content_ctl(enum content_ctl_state state, void *data)
|
|||||||
temporary_content = string_list_new();
|
temporary_content = string_list_new();
|
||||||
if (!temporary_content)
|
if (!temporary_content)
|
||||||
return false;
|
return false;
|
||||||
if (content_init_file(temporary_content))
|
if (content_file_init(temporary_content))
|
||||||
{
|
{
|
||||||
content_is_inited = true;
|
content_is_inited = true;
|
||||||
return true;
|
return true;
|
||||||
@ -1732,22 +1752,7 @@ bool content_ctl(enum content_ctl_state state, void *data)
|
|||||||
content_ctl(CONTENT_CTL_DEINIT, NULL);
|
content_ctl(CONTENT_CTL_DEINIT, NULL);
|
||||||
return false;
|
return false;
|
||||||
case CONTENT_CTL_TEMPORARY_FREE:
|
case CONTENT_CTL_TEMPORARY_FREE:
|
||||||
if (!temporary_content)
|
content_file_free(temporary_content);
|
||||||
return false;
|
|
||||||
|
|
||||||
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;
|
temporary_content = NULL;
|
||||||
break;
|
break;
|
||||||
case CONTENT_CTL_STREAM_INIT:
|
case CONTENT_CTL_STREAM_INIT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user