mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-11 03:55:45 +00:00
(Updater) Implement 'Update Assets'
This commit is contained in:
parent
9de889f735
commit
f3814c2b02
@ -1256,10 +1256,20 @@ static int action_ok_download_generic(const char *path,
|
|||||||
char s2[PATH_MAX_LENGTH] = {0};
|
char s2[PATH_MAX_LENGTH] = {0};
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
fill_pathname_join(s, settings->network.buildbot_url,
|
if (!strcmp(type_msg, "cb_update_assets"))
|
||||||
path, sizeof(s));
|
{
|
||||||
|
path = "assets.zip";
|
||||||
|
fill_pathname_join(s, settings->network.buildbot_assets_url,
|
||||||
|
"frontend/assets.zip", sizeof(s));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fill_pathname_join(s, settings->network.buildbot_url,
|
||||||
|
path, sizeof(s));
|
||||||
|
}
|
||||||
|
|
||||||
strlcpy(core_updater_path, path, sizeof(core_updater_path));
|
strlcpy(core_updater_path, path, sizeof(core_updater_path));
|
||||||
|
|
||||||
snprintf(s2, sizeof(s2),
|
snprintf(s2, sizeof(s2),
|
||||||
"%s %s.",
|
"%s %s.",
|
||||||
menu_hash_to_str(MENU_LABEL_VALUE_STARTING_DOWNLOAD),
|
menu_hash_to_str(MENU_LABEL_VALUE_STARTING_DOWNLOAD),
|
||||||
@ -1283,6 +1293,16 @@ static int action_ok_core_updater_download(const char *path,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int action_ok_update_assets(const char *path,
|
||||||
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_NETWORKING
|
||||||
|
action_ok_download_generic(path, label, type, idx, entry_idx,
|
||||||
|
"cb_update_assets");
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int action_ok_disk_cycle_tray_status(const char *path,
|
static int action_ok_disk_cycle_tray_status(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)
|
||||||
{
|
{
|
||||||
@ -1653,6 +1673,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
|
|||||||
case MENU_LABEL_SCREEN_RESOLUTION:
|
case MENU_LABEL_SCREEN_RESOLUTION:
|
||||||
cbs->action_ok = action_ok_video_resolution;
|
cbs->action_ok = action_ok_video_resolution;
|
||||||
break;
|
break;
|
||||||
|
case MENU_LABEL_UPDATE_ASSETS:
|
||||||
|
cbs->action_ok = action_ok_update_assets;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#define CB_CORE_UPDATER_DOWNLOAD 0x7412da7dU
|
#define CB_CORE_UPDATER_DOWNLOAD 0x7412da7dU
|
||||||
#define CB_CORE_UPDATER_LIST 0x32fd4f01U
|
#define CB_CORE_UPDATER_LIST 0x32fd4f01U
|
||||||
|
#define CB_UPDATE_ASSETS 0xbf85795eU
|
||||||
|
|
||||||
extern char core_updater_path[PATH_MAX_LENGTH];
|
extern char core_updater_path[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
@ -119,6 +120,48 @@ static int cb_core_updater_download(void *data, size_t len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cb_update_assets(void *data, size_t len)
|
||||||
|
{
|
||||||
|
const char *file_ext = NULL;
|
||||||
|
char output_path[PATH_MAX_LENGTH] = {0};
|
||||||
|
char msg[PATH_MAX_LENGTH] = {0};
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
fill_pathname_join(output_path, settings->assets_directory,
|
||||||
|
core_updater_path, sizeof(output_path));
|
||||||
|
|
||||||
|
if (!write_file(output_path, data, len))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
snprintf(msg, sizeof(msg), "Download complete: %s.",
|
||||||
|
core_updater_path);
|
||||||
|
|
||||||
|
rarch_main_msg_queue_push(msg, 1, 90, true);
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
file_ext = path_get_extension(output_path);
|
||||||
|
|
||||||
|
if (!settings->network.buildbot_auto_extract_archive)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!strcasecmp(file_ext,"zip"))
|
||||||
|
{
|
||||||
|
if (!zlib_parse_file(output_path, NULL, zlib_extract_core_callback,
|
||||||
|
|
||||||
|
(void*)settings->assets_directory))
|
||||||
|
RARCH_LOG("Could not process ZIP file.\n");
|
||||||
|
|
||||||
|
if (path_file_exists(output_path))
|
||||||
|
remove(output_path);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int rarch_main_data_http_con_iterate_transfer(http_handle_t *http)
|
static int rarch_main_data_http_con_iterate_transfer(http_handle_t *http)
|
||||||
{
|
{
|
||||||
if (!net_http_connection_iterate(http->connection.handle))
|
if (!net_http_connection_iterate(http->connection.handle))
|
||||||
@ -187,6 +230,9 @@ static int cb_http_conn_default(void *data_, size_t len)
|
|||||||
case CB_CORE_UPDATER_LIST:
|
case CB_CORE_UPDATER_LIST:
|
||||||
http->cb = &cb_core_updater_list;
|
http->cb = &cb_core_updater_list;
|
||||||
break;
|
break;
|
||||||
|
case CB_UPDATE_ASSETS:
|
||||||
|
http->cb = &cb_update_assets;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user