diff --git a/core_updater_list.c b/core_updater_list.c index 20985f75d9b..b7bb86ed479 100644 --- a/core_updater_list.c +++ b/core_updater_list.c @@ -26,7 +26,6 @@ #include #include -#include "configuration.h" #include "file_path_special.h" #include "core_info.h" @@ -400,14 +399,14 @@ static bool core_updater_list_set_crc( * associated paths to the specified core * updater list entry */ static bool core_updater_list_set_paths( - core_updater_list_entry_t *entry, const char *filename_str) + core_updater_list_entry_t *entry, + const char *path_dir_libretro, + const char *path_libretro_info, + const char *network_buildbot_url, + const char *filename_str) { - settings_t *settings = config_get_ptr(); char *last_underscore = NULL; char *tmp_url = NULL; - const char *path_dir_libretro = NULL; - const char *path_libretro_info = NULL; - const char *network_buildbot_url = NULL; char remote_core_path[PATH_MAX_LENGTH]; char local_core_path[PATH_MAX_LENGTH]; char local_info_path[PATH_MAX_LENGTH]; @@ -419,13 +418,9 @@ static bool core_updater_list_set_paths( local_info_path[0] = '\0'; display_name[0] = '\0'; - if (!entry || string_is_empty(filename_str) || !settings) + if (!entry || string_is_empty(filename_str)) return false; - path_dir_libretro = settings->paths.directory_libretro; - path_libretro_info = settings->paths.path_libretro_info; - network_buildbot_url = settings->paths.network_buildbot_url; - if (string_is_empty(path_dir_libretro) || string_is_empty(path_libretro_info) || string_is_empty(network_buildbot_url)) @@ -600,6 +595,9 @@ static bool core_updater_list_push_entry( * core updater list */ static void core_updater_list_add_entry( core_updater_list_t *core_list, + const char *path_dir_libretro, + const char *path_libretro_info, + const char *network_buildbot_url, struct string_list *network_core_entry_list) { const char *date_str = NULL; @@ -638,7 +636,12 @@ static void core_updater_list_add_entry( if (!core_updater_list_set_crc(&entry, crc_str)) goto error; - if (!core_updater_list_set_paths(&entry, filename_str)) + if (!core_updater_list_set_paths( + &entry, + path_dir_libretro, + path_libretro_info, + network_buildbot_url, + filename_str)) goto error; /* Add entry to list */ @@ -700,7 +703,11 @@ static void core_updater_list_qsort(core_updater_list_t *core_list) * core_updater_list_t object. * Returns false in the event of an error. */ bool core_updater_list_parse_network_data( - core_updater_list_t *core_list, const char *data, size_t len) + core_updater_list_t *core_list, + const char *path_dir_libretro, + const char *path_libretro_info, + const char *network_buildbot_url, + const char *data, size_t len) { struct string_list *network_core_list = NULL; struct string_list *network_core_entry_list = NULL; @@ -752,7 +759,11 @@ bool core_updater_list_parse_network_data( /* Parse listings info and add to core updater * list */ core_updater_list_add_entry( - core_list, network_core_entry_list); + core_list, + path_dir_libretro, + path_libretro_info, + network_buildbot_url, + network_core_entry_list); /* Clean up */ string_list_free(network_core_entry_list); diff --git a/core_updater_list.h b/core_updater_list.h index 3d1dae807e0..13cc7675474 100644 --- a/core_updater_list.h +++ b/core_updater_list.h @@ -136,7 +136,11 @@ bool core_updater_list_get_core( * core_updater_list_t object. * Returns false in the event of an error. */ bool core_updater_list_parse_network_data( - core_updater_list_t *core_list, const char *data, size_t len); + core_updater_list_t *core_list, + const char *path_dir_libretro, + const char *path_libretro_info, + const char *network_buildbot_url, + const char *data, size_t len); RETRO_END_DECLS diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 2a607e127bb..adf453bdbb0 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3168,7 +3168,10 @@ static unsigned menu_displaylist_parse_content_information( !settings->bools.content_runtime_log_aggregate)) { runtime_log_t *runtime_log = runtime_log_init( - content_path, core_path, + content_path, + core_path, + settings->paths.directory_runtime_log, + settings->paths.directory_playlist, (settings->uints.playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_PER_CORE)); if (runtime_log) diff --git a/retroarch.c b/retroarch.c index bd2443da776..c813893805a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5603,9 +5603,15 @@ static bool event_init_content(void) static void update_runtime_log(bool log_per_core) { + settings_t *settings = config_get_ptr(); + /* Initialise runtime log file */ runtime_log_t *runtime_log = runtime_log_init( - runtime_content_path, runtime_core_path, log_per_core); + runtime_content_path, + runtime_core_path, + settings->paths.directory_runtime_log, + settings->paths.directory_playlist, + log_per_core); if (!runtime_log) return; diff --git a/runtime_file.c b/runtime_file.c index 9a94c52ae0f..e9018f7fafe 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -264,8 +264,12 @@ static void runtime_log_read_file(runtime_log_t *runtime_log) /* Initialise runtime log, loading current parameters * if log file exists. Returned object must be free()'d. * Returns NULL if content_path and/or core_path are invalid */ -runtime_log_t *runtime_log_init(const char *content_path, - const char *core_path, bool log_per_core) +runtime_log_t *runtime_log_init( + const char *content_path, + const char *core_path, + const char *dir_runtime_log, + const char *dir_playlist, + bool log_per_core) { unsigned i; char content_name[PATH_MAX_LENGTH]; @@ -273,7 +277,6 @@ runtime_log_t *runtime_log_init(const char *content_path, char log_file_dir[PATH_MAX_LENGTH]; char log_file_path[PATH_MAX_LENGTH]; char tmp_buf[PATH_MAX_LENGTH]; - settings_t *settings = config_get_ptr(); core_info_list_t *core_info = NULL; runtime_log_t *runtime_log = NULL; const char *core_path_basename = NULL; @@ -284,12 +287,8 @@ runtime_log_t *runtime_log_init(const char *content_path, log_file_path[0] = '\0'; tmp_buf[0] = '\0'; - /* Error checking */ - if (!settings) - return NULL; - - if ( string_is_empty(settings->paths.directory_runtime_log) && - string_is_empty(settings->paths.directory_playlist)) + if ( string_is_empty(dir_runtime_log) && + string_is_empty(dir_playlist)) { RARCH_ERR("Runtime log directory is undefined - cannot save" " runtime log files.\n"); @@ -334,19 +333,18 @@ runtime_log_t *runtime_log_init(const char *content_path, return NULL; /* Get runtime log directory */ - if (string_is_empty(settings->paths.directory_runtime_log)) + if (string_is_empty(dir_runtime_log)) { /* If 'custom' runtime log path is undefined, * use default 'playlists/logs' directory... */ fill_pathname_join( tmp_buf, - settings->paths.directory_playlist, + dir_playlist, "logs", sizeof(tmp_buf)); } else - strlcpy(tmp_buf, - settings->paths.directory_runtime_log, sizeof(tmp_buf)); + strlcpy(tmp_buf, dir_runtime_log, sizeof(tmp_buf)); if (string_is_empty(tmp_buf)) return NULL; @@ -694,15 +692,11 @@ static void last_played_strftime(runtime_log_t *runtime_log, char *str, size_t l void runtime_log_get_last_played_str(runtime_log_t *runtime_log, char *str, size_t len, enum playlist_sublabel_last_played_style_type timedate_style) { - settings_t *settings = config_get_ptr(); int n = 0; char tmp[64]; tmp[0] = '\0'; - if (!settings) - return; - if (runtime_log) { /* Handle 12-hour clock options @@ -949,13 +943,14 @@ void runtime_log_convert_usec2hms(retro_time_t usec, * contents of associated log file */ void runtime_update_playlist(playlist_t *playlist, size_t idx) { + char runtime_str[64]; + char last_played_str[64]; + enum playlist_sublabel_last_played_style_type + timedate_style = PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS; settings_t *settings = config_get_ptr(); runtime_log_t *runtime_log = NULL; const struct playlist_entry *entry = NULL; struct playlist_entry update_entry = {0}; - enum playlist_sublabel_last_played_style_type timedate_style; - char runtime_str[64]; - char last_played_str[64]; /* Sanity check */ if (!playlist || !settings) @@ -971,9 +966,8 @@ void runtime_update_playlist(playlist_t *playlist, size_t idx) /* Get current last played formatting type * > Have to include a 'HAVE_MENU' check here... */ #ifdef HAVE_MENU - timedate_style = (enum playlist_sublabel_last_played_style_type)settings->uints.playlist_sublabel_last_played_style; -#else - timedate_style = PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS; + timedate_style = (enum playlist_sublabel_last_played_style_type) + settings->uints.playlist_sublabel_last_played_style; #endif /* 'Attach' runtime/last played strings */ @@ -986,7 +980,11 @@ void runtime_update_playlist(playlist_t *playlist, size_t idx) playlist_get_index(playlist, idx, &entry); /* Attempt to open log file */ - runtime_log = runtime_log_init(entry->path, entry->core_path, + runtime_log = runtime_log_init( + entry->path, + entry->core_path, + settings->paths.directory_runtime_log, + settings->paths.directory_playlist, (settings->uints.playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_PER_CORE)); if (runtime_log) @@ -1015,6 +1013,7 @@ void runtime_update_playlist(playlist_t *playlist, size_t idx) free(runtime_log); } +#ifdef HAVE_MENU /* Ozone requires runtime/last played strings to be * populated even when no runtime is recorded */ if (string_is_equal(settings->arrays.menu_driver, "ozone")) @@ -1025,6 +1024,7 @@ void runtime_update_playlist(playlist_t *playlist, size_t idx) runtime_log_get_last_played_str(NULL, last_played_str, sizeof(last_played_str), timedate_style); } } +#endif /* Update playlist */ playlist_update_runtime(playlist, idx, &update_entry, false); diff --git a/runtime_file.h b/runtime_file.h index 3ffce67277a..9776cf7a88d 100644 --- a/runtime_file.h +++ b/runtime_file.h @@ -63,7 +63,12 @@ typedef struct /* Initialise runtime log, loading current parameters * if log file exists. Returned object must be free()'d. * Returns NULL if content_path and/or core_path are invalid */ -runtime_log_t *runtime_log_init(const char *content_path, const char *core_path, bool log_per_core); +runtime_log_t *runtime_log_init( + const char *content_path, + const char *core_path, + const char *dir_runtime_log, + const char *dir_playlist, + bool log_per_core); /* Setters */ diff --git a/tasks/task_core_updater.c b/tasks/task_core_updater.c index 397101c0b50..73571f7bd6a 100644 --- a/tasks/task_core_updater.c +++ b/tasks/task_core_updater.c @@ -295,10 +295,15 @@ static void task_core_updater_get_list_handler(retro_task_t *task) break; case CORE_UPDATER_LIST_END: { + settings_t *settings = config_get_ptr(); + /* Parse HTTP transfer data */ if (list_handle->http_data) core_updater_list_parse_network_data( list_handle->core_list, + settings->paths.directory_libretro, + settings->paths.path_libretro_info, + settings->paths.network_buildbot_url, list_handle->http_data->data, list_handle->http_data->len);