mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
Cleanups
This commit is contained in:
parent
f9f0d4abb6
commit
45b806aed8
@ -32,26 +32,20 @@
|
|||||||
#include "../../verbosity.h"
|
#include "../../verbosity.h"
|
||||||
#include "../../tasks/tasks.h"
|
#include "../../tasks/tasks.h"
|
||||||
|
|
||||||
#define CB_CORE_UPDATER_DOWNLOAD 0x7412da7dU
|
|
||||||
#define CB_CORE_UPDATER_LIST 0x32fd4f01U
|
|
||||||
#define CB_UPDATE_ASSETS 0xbf85795eU
|
|
||||||
#define CB_UPDATE_CORE_INFO_FILES 0xe6084091U
|
|
||||||
#define CB_UPDATE_AUTOCONFIG_PROFILES 0x28ada67dU
|
|
||||||
#define CB_UPDATE_CHEATS 0xc360fec3U
|
|
||||||
#define CB_UPDATE_OVERLAYS 0x699009a0U
|
|
||||||
#define CB_UPDATE_DATABASES 0x931eb8d3U
|
|
||||||
#define CB_UPDATE_SHADERS_GLSL 0x0121a186U
|
|
||||||
#define CB_UPDATE_SHADERS_CG 0xc93a53feU
|
|
||||||
#define CB_CORE_CONTENT_LIST 0xebc51227U
|
|
||||||
#define CB_CORE_CONTENT_DOWNLOAD 0x03b3c0a3U
|
|
||||||
#define CB_LAKKA_DOWNLOAD 0x54eaa904U
|
|
||||||
|
|
||||||
#ifndef BIND_ACTION_DEFERRED_PUSH
|
#ifndef BIND_ACTION_DEFERRED_PUSH
|
||||||
#define BIND_ACTION_DEFERRED_PUSH(cbs, name) \
|
#define BIND_ACTION_DEFERRED_PUSH(cbs, name) \
|
||||||
cbs->action_deferred_push = name; \
|
cbs->action_deferred_push = name; \
|
||||||
cbs->action_deferred_push_ident = #name;
|
cbs->action_deferred_push_ident = #name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PUSH_ARCHIVE_OPEN_DETECT_CORE = 0,
|
||||||
|
PUSH_ARCHIVE_OPEN,
|
||||||
|
PUSH_DEFAULT,
|
||||||
|
PUSH_DETECT_CORE_LIST
|
||||||
|
};
|
||||||
|
|
||||||
static int deferred_push_dlist(menu_displaylist_info_t *info, unsigned val)
|
static int deferred_push_dlist(menu_displaylist_info_t *info, unsigned val)
|
||||||
{
|
{
|
||||||
if (menu_displaylist_push_list(info, val) != 0)
|
if (menu_displaylist_push_list(info, val) != 0)
|
||||||
@ -299,153 +293,6 @@ static int deferred_push_disk_options(menu_displaylist_info_t *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
static void cb_decompressed(void *task_data, void *user_data, const char *err)
|
|
||||||
{
|
|
||||||
decompress_task_data_t *dec = (decompress_task_data_t*)task_data;
|
|
||||||
unsigned type_hash = (uintptr_t)user_data;
|
|
||||||
|
|
||||||
if (dec && !err)
|
|
||||||
{
|
|
||||||
if (type_hash == CB_CORE_UPDATER_DOWNLOAD)
|
|
||||||
event_cmd_ctl(EVENT_CMD_CORE_INFO_INIT, NULL);
|
|
||||||
else if (type_hash == CB_UPDATE_ASSETS)
|
|
||||||
event_cmd_ctl(EVENT_CMD_REINIT, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
RARCH_ERR("%s", err);
|
|
||||||
|
|
||||||
if (dec)
|
|
||||||
{
|
|
||||||
if (path_file_exists(dec->source_file))
|
|
||||||
remove(dec->source_file);
|
|
||||||
|
|
||||||
free(dec->source_file);
|
|
||||||
free(dec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* expects http_transfer_t*, menu_file_transfer_t* */
|
|
||||||
void cb_generic_download(void *task_data, void *user_data, const char *err)
|
|
||||||
{
|
|
||||||
char output_path[PATH_MAX_LENGTH];
|
|
||||||
char shaderdir[PATH_MAX_LENGTH];
|
|
||||||
const char *file_ext = NULL;
|
|
||||||
const char *dir_path = NULL;
|
|
||||||
menu_file_transfer_t *transf = (menu_file_transfer_t*)user_data;
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
|
||||||
|
|
||||||
if (!data || !data->data | !transf)
|
|
||||||
goto finish;
|
|
||||||
|
|
||||||
/* we have to determine dir_path at the time of writting or else
|
|
||||||
* we'd run into races when the user changes the setting during an
|
|
||||||
* http transfer. */
|
|
||||||
switch (transf->type_hash)
|
|
||||||
{
|
|
||||||
case CB_CORE_UPDATER_DOWNLOAD:
|
|
||||||
dir_path = settings->libretro_directory;
|
|
||||||
break;
|
|
||||||
case CB_CORE_CONTENT_DOWNLOAD:
|
|
||||||
dir_path = settings->core_assets_directory;
|
|
||||||
break;
|
|
||||||
case CB_UPDATE_CORE_INFO_FILES:
|
|
||||||
dir_path = settings->libretro_info_path;
|
|
||||||
break;
|
|
||||||
case CB_UPDATE_ASSETS:
|
|
||||||
dir_path = settings->assets_directory;
|
|
||||||
break;
|
|
||||||
case CB_UPDATE_AUTOCONFIG_PROFILES:
|
|
||||||
dir_path = settings->input.autoconfig_dir;
|
|
||||||
break;
|
|
||||||
case CB_UPDATE_DATABASES:
|
|
||||||
dir_path = settings->content_database;
|
|
||||||
break;
|
|
||||||
case CB_UPDATE_OVERLAYS:
|
|
||||||
dir_path = settings->overlay_directory;
|
|
||||||
break;
|
|
||||||
case CB_UPDATE_CHEATS:
|
|
||||||
dir_path = settings->cheat_database;
|
|
||||||
break;
|
|
||||||
case CB_UPDATE_SHADERS_CG:
|
|
||||||
case CB_UPDATE_SHADERS_GLSL:
|
|
||||||
{
|
|
||||||
const char *dirname = transf->type_hash == CB_UPDATE_SHADERS_CG ?
|
|
||||||
"shaders_cg" : "shaders_glsl";
|
|
||||||
|
|
||||||
fill_pathname_join(shaderdir, settings->video.shader_dir, dirname,
|
|
||||||
sizeof(shaderdir));
|
|
||||||
if (!path_file_exists(shaderdir))
|
|
||||||
if (!path_mkdir(shaderdir))
|
|
||||||
goto finish;
|
|
||||||
|
|
||||||
dir_path = shaderdir;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CB_LAKKA_DOWNLOAD:
|
|
||||||
dir_path = "/storage/.update/"; /* TODO unhardcode this ? */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
RARCH_WARN("Unknown transfer type '%u' bailing out.\n",
|
|
||||||
transf->type_hash);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_pathname_join(output_path, dir_path,
|
|
||||||
transf->path, sizeof(output_path));
|
|
||||||
|
|
||||||
/* Make sure the directory exists */
|
|
||||||
path_basedir(output_path);
|
|
||||||
if (!path_mkdir(output_path))
|
|
||||||
{
|
|
||||||
err = "Failed to create the directory.";
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_pathname_join(output_path, dir_path,
|
|
||||||
transf->path, sizeof(output_path));
|
|
||||||
|
|
||||||
if (!retro_write_file(output_path, data->data, data->len))
|
|
||||||
{
|
|
||||||
err = "Write failed.";
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB
|
|
||||||
file_ext = path_get_extension(output_path);
|
|
||||||
|
|
||||||
if (!settings->network.buildbot_auto_extract_archive)
|
|
||||||
goto finish;
|
|
||||||
|
|
||||||
if (string_is_equal_noncase(file_ext, "zip"))
|
|
||||||
{
|
|
||||||
rarch_task_push_decompress(output_path, dir_path, NULL, NULL, NULL,
|
|
||||||
cb_decompressed, (void*)(uintptr_t)transf->type_hash);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (transf->type_hash == CB_CORE_UPDATER_DOWNLOAD)
|
|
||||||
event_cmd_ctl(EVENT_CMD_CORE_INFO_INIT, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
finish:
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
RARCH_ERR("Download of '%s' failed: %s\n",
|
|
||||||
(transf ? transf->path: "unknown"), err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
if (data->data)
|
|
||||||
free(data->data);
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transf)
|
|
||||||
free(transf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int deferred_push_core_updater_list(menu_displaylist_info_t *info)
|
static int deferred_push_core_updater_list(menu_displaylist_info_t *info)
|
||||||
{
|
{
|
||||||
return deferred_push_dlist(info, DISPLAYLIST_CORES_UPDATER);
|
return deferred_push_dlist(info, DISPLAYLIST_CORES_UPDATER);
|
||||||
@ -473,13 +320,6 @@ static int deferred_archive_action(menu_displaylist_info_t *info)
|
|||||||
return deferred_push_dlist(info, DISPLAYLIST_ARCHIVE_ACTION);
|
return deferred_push_dlist(info, DISPLAYLIST_ARCHIVE_ACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PUSH_ARCHIVE_OPEN_DETECT_CORE = 0,
|
|
||||||
PUSH_ARCHIVE_OPEN,
|
|
||||||
PUSH_DEFAULT,
|
|
||||||
PUSH_DETECT_CORE_LIST
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int general_push(menu_displaylist_info_t *info,
|
static int general_push(menu_displaylist_info_t *info,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <retro_stat.h>
|
#include <retro_stat.h>
|
||||||
|
#include <retro_file.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
#include "../menu_driver.h"
|
#include "../menu_driver.h"
|
||||||
@ -1217,6 +1218,156 @@ static int action_ok_save_state(const char *path,
|
|||||||
return generic_action_ok_command(EVENT_CMD_RESUME);
|
return generic_action_ok_command(EVENT_CMD_RESUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_NETWORKING
|
||||||
|
static void cb_decompressed(void *task_data, void *user_data, const char *err)
|
||||||
|
{
|
||||||
|
decompress_task_data_t *dec = (decompress_task_data_t*)task_data;
|
||||||
|
unsigned type_hash = (uintptr_t)user_data;
|
||||||
|
|
||||||
|
if (dec && !err)
|
||||||
|
{
|
||||||
|
if (type_hash == CB_CORE_UPDATER_DOWNLOAD)
|
||||||
|
event_cmd_ctl(EVENT_CMD_CORE_INFO_INIT, NULL);
|
||||||
|
else if (type_hash == CB_UPDATE_ASSETS)
|
||||||
|
event_cmd_ctl(EVENT_CMD_REINIT, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
RARCH_ERR("%s", err);
|
||||||
|
|
||||||
|
if (dec)
|
||||||
|
{
|
||||||
|
if (path_file_exists(dec->source_file))
|
||||||
|
remove(dec->source_file);
|
||||||
|
|
||||||
|
free(dec->source_file);
|
||||||
|
free(dec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* expects http_transfer_t*, menu_file_transfer_t* */
|
||||||
|
static void cb_generic_download(void *task_data,
|
||||||
|
void *user_data, const char *err)
|
||||||
|
{
|
||||||
|
char output_path[PATH_MAX_LENGTH];
|
||||||
|
char shaderdir[PATH_MAX_LENGTH];
|
||||||
|
const char *file_ext = NULL;
|
||||||
|
const char *dir_path = NULL;
|
||||||
|
menu_file_transfer_t *transf = (menu_file_transfer_t*)user_data;
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
||||||
|
|
||||||
|
if (!data || !data->data | !transf)
|
||||||
|
goto finish;
|
||||||
|
|
||||||
|
/* we have to determine dir_path at the time of writting or else
|
||||||
|
* we'd run into races when the user changes the setting during an
|
||||||
|
* http transfer. */
|
||||||
|
switch (transf->type_hash)
|
||||||
|
{
|
||||||
|
case CB_CORE_UPDATER_DOWNLOAD:
|
||||||
|
dir_path = settings->libretro_directory;
|
||||||
|
break;
|
||||||
|
case CB_CORE_CONTENT_DOWNLOAD:
|
||||||
|
dir_path = settings->core_assets_directory;
|
||||||
|
break;
|
||||||
|
case CB_UPDATE_CORE_INFO_FILES:
|
||||||
|
dir_path = settings->libretro_info_path;
|
||||||
|
break;
|
||||||
|
case CB_UPDATE_ASSETS:
|
||||||
|
dir_path = settings->assets_directory;
|
||||||
|
break;
|
||||||
|
case CB_UPDATE_AUTOCONFIG_PROFILES:
|
||||||
|
dir_path = settings->input.autoconfig_dir;
|
||||||
|
break;
|
||||||
|
case CB_UPDATE_DATABASES:
|
||||||
|
dir_path = settings->content_database;
|
||||||
|
break;
|
||||||
|
case CB_UPDATE_OVERLAYS:
|
||||||
|
dir_path = settings->overlay_directory;
|
||||||
|
break;
|
||||||
|
case CB_UPDATE_CHEATS:
|
||||||
|
dir_path = settings->cheat_database;
|
||||||
|
break;
|
||||||
|
case CB_UPDATE_SHADERS_CG:
|
||||||
|
case CB_UPDATE_SHADERS_GLSL:
|
||||||
|
{
|
||||||
|
const char *dirname = transf->type_hash == CB_UPDATE_SHADERS_CG ?
|
||||||
|
"shaders_cg" : "shaders_glsl";
|
||||||
|
|
||||||
|
fill_pathname_join(shaderdir, settings->video.shader_dir, dirname,
|
||||||
|
sizeof(shaderdir));
|
||||||
|
if (!path_file_exists(shaderdir))
|
||||||
|
if (!path_mkdir(shaderdir))
|
||||||
|
goto finish;
|
||||||
|
|
||||||
|
dir_path = shaderdir;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CB_LAKKA_DOWNLOAD:
|
||||||
|
dir_path = "/storage/.update/"; /* TODO unhardcode this ? */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
RARCH_WARN("Unknown transfer type '%u' bailing out.\n",
|
||||||
|
transf->type_hash);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fill_pathname_join(output_path, dir_path,
|
||||||
|
transf->path, sizeof(output_path));
|
||||||
|
|
||||||
|
/* Make sure the directory exists */
|
||||||
|
path_basedir(output_path);
|
||||||
|
if (!path_mkdir(output_path))
|
||||||
|
{
|
||||||
|
err = "Failed to create the directory.";
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
fill_pathname_join(output_path, dir_path,
|
||||||
|
transf->path, sizeof(output_path));
|
||||||
|
|
||||||
|
if (!retro_write_file(output_path, data->data, data->len))
|
||||||
|
{
|
||||||
|
err = "Write failed.";
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
file_ext = path_get_extension(output_path);
|
||||||
|
|
||||||
|
if (!settings->network.buildbot_auto_extract_archive)
|
||||||
|
goto finish;
|
||||||
|
|
||||||
|
if (string_is_equal_noncase(file_ext, "zip"))
|
||||||
|
{
|
||||||
|
rarch_task_push_decompress(output_path, dir_path, NULL, NULL, NULL,
|
||||||
|
cb_decompressed, (void*)(uintptr_t)transf->type_hash);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (transf->type_hash == CB_CORE_UPDATER_DOWNLOAD)
|
||||||
|
event_cmd_ctl(EVENT_CMD_CORE_INFO_INIT, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
finish:
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
RARCH_ERR("Download of '%s' failed: %s\n",
|
||||||
|
(transf ? transf->path: "unknown"), err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data)
|
||||||
|
{
|
||||||
|
if (data->data)
|
||||||
|
free(data->data);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transf)
|
||||||
|
free(transf);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int action_ok_download_generic(const char *path,
|
static int action_ok_download_generic(const char *path,
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx,
|
const char *label, unsigned type, size_t idx, size_t entry_idx,
|
||||||
const char *type_msg)
|
const char *type_msg)
|
||||||
|
@ -23,6 +23,20 @@
|
|||||||
#include "menu_entries.h"
|
#include "menu_entries.h"
|
||||||
#include "menu_hash.h"
|
#include "menu_hash.h"
|
||||||
|
|
||||||
|
#define CB_CORE_UPDATER_DOWNLOAD 0x7412da7dU
|
||||||
|
#define CB_CORE_UPDATER_LIST 0x32fd4f01U
|
||||||
|
#define CB_UPDATE_ASSETS 0xbf85795eU
|
||||||
|
#define CB_UPDATE_CORE_INFO_FILES 0xe6084091U
|
||||||
|
#define CB_UPDATE_AUTOCONFIG_PROFILES 0x28ada67dU
|
||||||
|
#define CB_UPDATE_CHEATS 0xc360fec3U
|
||||||
|
#define CB_UPDATE_OVERLAYS 0x699009a0U
|
||||||
|
#define CB_UPDATE_DATABASES 0x931eb8d3U
|
||||||
|
#define CB_UPDATE_SHADERS_GLSL 0x0121a186U
|
||||||
|
#define CB_UPDATE_SHADERS_CG 0xc93a53feU
|
||||||
|
#define CB_CORE_CONTENT_LIST 0xebc51227U
|
||||||
|
#define CB_CORE_CONTENT_DOWNLOAD 0x03b3c0a3U
|
||||||
|
#define CB_LAKKA_DOWNLOAD 0x54eaa904U
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ACTION_OK_DL_DEFAULT = 0,
|
ACTION_OK_DL_DEFAULT = 0,
|
||||||
@ -209,7 +223,6 @@ typedef struct
|
|||||||
uint32_t type_hash;
|
uint32_t type_hash;
|
||||||
char path[PATH_MAX_LENGTH];
|
char path[PATH_MAX_LENGTH];
|
||||||
} menu_file_transfer_t;
|
} menu_file_transfer_t;
|
||||||
void cb_generic_download(void *task_data, void *user_data, const char *err);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user