mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Cleanups:
* Combine early return and assignment lines * use path_basename_nocompression when possible * Move variables to proper scope
This commit is contained in:
parent
f7194e167f
commit
c4fb055fdb
@ -3884,7 +3884,7 @@ bool config_load_override(void *data)
|
||||
{
|
||||
fill_pathname_parent_dir_name(content_dir_name,
|
||||
rarch_path_basename, sizeof(content_dir_name));
|
||||
game_name = path_basename(rarch_path_basename);
|
||||
game_name = path_basename_nocompression(rarch_path_basename);
|
||||
|
||||
fill_pathname_join_special_ext(game_path,
|
||||
config_directory, core_name,
|
||||
@ -4096,7 +4096,7 @@ bool config_load_remap(const char *directory_input_remapping,
|
||||
{
|
||||
fill_pathname_parent_dir_name(content_dir_name,
|
||||
rarch_path_basename, sizeof(content_dir_name));
|
||||
game_name = path_basename(rarch_path_basename);
|
||||
game_name = path_basename_nocompression(rarch_path_basename);
|
||||
|
||||
fill_pathname_join_special_ext(game_path,
|
||||
directory_input_remapping, core_name,
|
||||
@ -5013,7 +5013,7 @@ bool config_save_overrides(enum override_type type, void *data)
|
||||
ret = config_file_write(conf, core_path, true);
|
||||
break;
|
||||
case OVERRIDE_GAME:
|
||||
game_name = path_basename(rarch_path_basename);
|
||||
game_name = path_basename_nocompression(rarch_path_basename);
|
||||
fill_pathname_join_special_ext(game_path,
|
||||
config_directory, core_name,
|
||||
game_name,
|
||||
|
@ -431,10 +431,10 @@ bool gfx_thumbnail_set_content_image(
|
||||
bool gfx_thumbnail_set_content_playlist(
|
||||
gfx_thumbnail_path_data_t *path_data, playlist_t *playlist, size_t idx)
|
||||
{
|
||||
const char *content_path = NULL;
|
||||
const char *content_label = NULL;
|
||||
const char *core_name = NULL;
|
||||
const char *db_name = NULL;
|
||||
const char *content_path = NULL;
|
||||
const char *content_label = NULL;
|
||||
const char *core_name = NULL;
|
||||
const char *db_name = NULL;
|
||||
const struct playlist_entry *entry = NULL;
|
||||
|
||||
if (!path_data)
|
||||
@ -442,19 +442,19 @@ bool gfx_thumbnail_set_content_playlist(
|
||||
|
||||
/* When content is updated, must regenerate right/left
|
||||
* thumbnail paths */
|
||||
path_data->right_path[0] = '\0';
|
||||
path_data->left_path[0] = '\0';
|
||||
path_data->right_path[0] = '\0';
|
||||
path_data->left_path[0] = '\0';
|
||||
|
||||
/* 'Reset' path_data content strings */
|
||||
path_data->content_path[0] = '\0';
|
||||
path_data->content_label[0] = '\0';
|
||||
path_data->content_core_name[0] = '\0';
|
||||
path_data->content_db_name[0] = '\0';
|
||||
path_data->content_img[0] = '\0';
|
||||
path_data->content_path[0] = '\0';
|
||||
path_data->content_label[0] = '\0';
|
||||
path_data->content_core_name[0] = '\0';
|
||||
path_data->content_db_name[0] = '\0';
|
||||
path_data->content_img[0] = '\0';
|
||||
|
||||
/* Must also reset playlist thumbnail display modes */
|
||||
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
path_data->playlist_left_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
path_data->playlist_right_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
path_data->playlist_left_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
|
||||
|
||||
if (!playlist)
|
||||
return false;
|
||||
@ -494,7 +494,7 @@ bool gfx_thumbnail_set_content_playlist(
|
||||
content_label, sizeof(path_data->content_label));
|
||||
else
|
||||
fill_pathname(path_data->content_label,
|
||||
path_basename(content_path),
|
||||
path_basename_nocompression(content_path),
|
||||
"", sizeof(path_data->content_label));
|
||||
|
||||
/* Determine content image name */
|
||||
@ -560,11 +560,9 @@ bool gfx_thumbnail_update_path(
|
||||
{
|
||||
char content_dir[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *type = gfx_thumbnail_get_type(settings,
|
||||
path_data, thumbnail_id);
|
||||
const char *system_name = NULL;
|
||||
char *thumbnail_path = NULL;
|
||||
const char *dir_thumbnails = settings ? settings->paths.directory_thumbnails : NULL;
|
||||
const char *dir_thumbnails = NULL;
|
||||
|
||||
if (!path_data)
|
||||
return false;
|
||||
@ -584,6 +582,9 @@ bool gfx_thumbnail_update_path(
|
||||
|
||||
thumbnail_path[0] = '\0';
|
||||
content_dir[0] = '\0';
|
||||
|
||||
if (settings)
|
||||
dir_thumbnails = settings->paths.directory_thumbnails;
|
||||
|
||||
/* Sundry error checking */
|
||||
if (string_is_empty(dir_thumbnails))
|
||||
@ -595,10 +596,10 @@ bool gfx_thumbnail_update_path(
|
||||
/* Generate new path */
|
||||
|
||||
/* > Check path_data for empty strings */
|
||||
if (string_is_empty(path_data->content_path) ||
|
||||
string_is_empty(path_data->content_img) ||
|
||||
(string_is_empty(path_data->system) &&
|
||||
string_is_empty(path_data->content_db_name)))
|
||||
if ( string_is_empty(path_data->content_path)
|
||||
|| string_is_empty(path_data->content_img)
|
||||
|| ( string_is_empty(path_data->system)
|
||||
&& string_is_empty(path_data->content_db_name)))
|
||||
return false;
|
||||
|
||||
/* > Get current system */
|
||||
@ -636,6 +637,9 @@ bool gfx_thumbnail_update_path(
|
||||
else
|
||||
{
|
||||
char tmp_buf[PATH_MAX_LENGTH];
|
||||
const char *type = gfx_thumbnail_get_type(settings,
|
||||
path_data, thumbnail_id);
|
||||
|
||||
tmp_buf[0] = '\0';
|
||||
|
||||
/* > Normal content: assemble path */
|
||||
@ -799,9 +803,7 @@ bool gfx_thumbnail_get_content_dir(
|
||||
if (!path_data || string_is_empty(path_data->content_path))
|
||||
return false;
|
||||
|
||||
last_slash = find_last_slash(path_data->content_path);
|
||||
|
||||
if (!last_slash)
|
||||
if (!(last_slash = find_last_slash(path_data->content_path)))
|
||||
return false;
|
||||
|
||||
path_length = last_slash + 1 - path_data->content_path;
|
||||
|
@ -3677,7 +3677,7 @@ static int action_ok_remap_file_flush(const char *path,
|
||||
success = input_remapping_save_file(path_remapfile);
|
||||
|
||||
/* Get remap file name for display purposes */
|
||||
remapfile = path_basename(path_remapfile);
|
||||
remapfile = path_basename_nocompression(path_remapfile);
|
||||
}
|
||||
|
||||
if (string_is_empty(remapfile))
|
||||
|
@ -2984,8 +2984,9 @@ static int playlist_qsort_func(const struct playlist_entry *a,
|
||||
goto end;
|
||||
|
||||
if (!string_is_empty(a->path))
|
||||
fill_pathname(a_fallback_label, path_basename(a->path),
|
||||
"", PATH_MAX_LENGTH * sizeof(char));
|
||||
fill_pathname(a_fallback_label,
|
||||
path_basename_nocompression(a->path),
|
||||
"", PATH_MAX_LENGTH * sizeof(char));
|
||||
/* If filename is also empty, use core name
|
||||
* instead -> this matches the behaviour of
|
||||
* menu_displaylist_parse_playlist() */
|
||||
@ -3008,7 +3009,8 @@ static int playlist_qsort_func(const struct playlist_entry *a,
|
||||
goto end;
|
||||
|
||||
if (!string_is_empty(b->path))
|
||||
fill_pathname(b_fallback_label, path_basename(b->path), "",
|
||||
fill_pathname(b_fallback_label,
|
||||
path_basename_nocompression(b->path), "",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
else if (!string_is_empty(b->core_name))
|
||||
strlcpy(b_fallback_label, b->core_name, PATH_MAX_LENGTH * sizeof(char));
|
||||
|
@ -972,7 +972,8 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
|
||||
msg[0] = '\0';
|
||||
|
||||
strlcpy(msg, msg_hash_to_str(MSG_CORE_RESTORATION_INVALID_CONTENT), sizeof(msg));
|
||||
strlcat(msg, backup_filename ? backup_filename : "", sizeof(msg));
|
||||
if (backup_filename)
|
||||
strlcat(msg, backup_filename, sizeof(msg));
|
||||
|
||||
RARCH_ERR("[core restore] Invalid core file selected: %s\n", backup_path);
|
||||
runloop_msg_queue_push(msg, 1, 100, true,
|
||||
@ -1002,9 +1003,9 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
|
||||
msg[0] = '\0';
|
||||
|
||||
strlcpy(msg,
|
||||
(backup_type == CORE_BACKUP_TYPE_ARCHIVE) ?
|
||||
msg_hash_to_str(MSG_CORE_RESTORATION_DISABLED) :
|
||||
msg_hash_to_str(MSG_CORE_INSTALLATION_DISABLED),
|
||||
(backup_type == CORE_BACKUP_TYPE_ARCHIVE)
|
||||
? msg_hash_to_str(MSG_CORE_RESTORATION_DISABLED)
|
||||
: msg_hash_to_str(MSG_CORE_INSTALLATION_DISABLED),
|
||||
sizeof(msg));
|
||||
strlcat(msg, core_name, sizeof(msg));
|
||||
|
||||
@ -1023,9 +1024,7 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
|
||||
goto error;
|
||||
|
||||
/* Configure handle */
|
||||
backup_handle = (core_backup_handle_t*)calloc(1, sizeof(core_backup_handle_t));
|
||||
|
||||
if (!backup_handle)
|
||||
if (!(backup_handle = (core_backup_handle_t*)calloc(1, sizeof(core_backup_handle_t))))
|
||||
goto error;
|
||||
|
||||
backup_handle->dir_core_assets = NULL;
|
||||
@ -1050,9 +1049,7 @@ bool task_push_core_restore(const char *backup_path, const char *dir_libretro,
|
||||
backup_handle->status = CORE_RESTORE_GET_CORE_CRC;
|
||||
|
||||
/* Create task */
|
||||
task = task_init();
|
||||
|
||||
if (!task)
|
||||
if (!(task = task_init()))
|
||||
goto error;
|
||||
|
||||
/* Get initial task title */
|
||||
|
@ -197,9 +197,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
if (!task)
|
||||
goto task_finished;
|
||||
|
||||
manual_scan = (manual_scan_handle_t*)task->state;
|
||||
|
||||
if (!manual_scan)
|
||||
if (!(manual_scan = (manual_scan_handle_t*)task->state))
|
||||
goto task_finished;
|
||||
|
||||
if (task_get_cancelled(task))
|
||||
@ -215,10 +213,9 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
manual_scan->task_config->file_exts, "|");
|
||||
|
||||
/* Get content list */
|
||||
manual_scan->content_list = manual_content_scan_get_content_list(
|
||||
manual_scan->task_config);
|
||||
|
||||
if (!manual_scan->content_list)
|
||||
if (!(manual_scan->content_list
|
||||
= manual_content_scan_get_content_list(
|
||||
manual_scan->task_config)))
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_INVALID_CONTENT),
|
||||
@ -232,10 +229,9 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
/* Load DAT file, if required */
|
||||
if (!string_is_empty(manual_scan->task_config->dat_file_path))
|
||||
{
|
||||
manual_scan->dat_file =
|
||||
logiqx_dat_init(manual_scan->task_config->dat_file_path);
|
||||
|
||||
if (!manual_scan->dat_file)
|
||||
if (!(manual_scan->dat_file =
|
||||
logiqx_dat_init(
|
||||
manual_scan->task_config->dat_file_path)))
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_DAT_FILE_LOAD_ERROR),
|
||||
@ -246,9 +242,8 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
}
|
||||
|
||||
/* Open playlist */
|
||||
manual_scan->playlist = playlist_init(&manual_scan->playlist_config);
|
||||
|
||||
if (!manual_scan->playlist)
|
||||
if (!(manual_scan->playlist =
|
||||
playlist_init(&manual_scan->playlist_config)))
|
||||
goto task_finished;
|
||||
|
||||
/* Reset playlist, if required */
|
||||
@ -256,7 +251,8 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
playlist_clear(manual_scan->playlist);
|
||||
|
||||
/* Get initial playlist size */
|
||||
manual_scan->playlist_size = playlist_size(manual_scan->playlist);
|
||||
manual_scan->playlist_size =
|
||||
playlist_size(manual_scan->playlist);
|
||||
|
||||
/* Set default core, if required */
|
||||
if (manual_scan->task_config->core_set)
|
||||
@ -370,8 +366,8 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
|
||||
if (!string_is_empty(content_path))
|
||||
{
|
||||
const char *content_file = path_basename(content_path);
|
||||
char task_title[PATH_MAX_LENGTH];
|
||||
const char *content_file = path_basename(content_path);
|
||||
|
||||
task_title[0] = '\0';
|
||||
|
||||
@ -386,7 +382,8 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
strlcat(task_title, content_file, sizeof(task_title));
|
||||
|
||||
task_set_title(task, strdup(task_title));
|
||||
task_set_progress(task, (manual_scan->content_list_index * 100) /
|
||||
task_set_progress(task,
|
||||
(manual_scan->content_list_index * 100) /
|
||||
manual_scan->content_list_size);
|
||||
|
||||
/* Add content to playlist */
|
||||
@ -429,9 +426,9 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
|
||||
if (!string_is_empty(m3u_path))
|
||||
{
|
||||
const char *m3u_name = path_basename(m3u_path);
|
||||
m3u_file_t *m3u_file = NULL;
|
||||
char task_title[PATH_MAX_LENGTH];
|
||||
const char *m3u_name = path_basename_nocompression(m3u_path);
|
||||
m3u_file_t *m3u_file = NULL;
|
||||
|
||||
task_title[0] = '\0';
|
||||
|
||||
@ -450,9 +447,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
|
||||
manual_scan->m3u_list->size);
|
||||
|
||||
/* Load M3U file */
|
||||
m3u_file = m3u_file_init(m3u_path);
|
||||
|
||||
if (m3u_file)
|
||||
if ((m3u_file = m3u_file_init(m3u_path)))
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@ -523,14 +518,10 @@ static bool task_manual_content_scan_finder(retro_task_t *task, void *user_data)
|
||||
|
||||
if (!task || !user_data)
|
||||
return false;
|
||||
|
||||
if (task->handler != task_manual_content_scan_handler)
|
||||
return false;
|
||||
|
||||
manual_scan = (manual_scan_handle_t*)task->state;
|
||||
if (!manual_scan)
|
||||
if (!(manual_scan = (manual_scan_handle_t*)task->state))
|
||||
return false;
|
||||
|
||||
return string_is_equal(
|
||||
(const char*)user_data, manual_scan->playlist_config.path);
|
||||
}
|
||||
@ -542,16 +533,18 @@ bool task_push_manual_content_scan(
|
||||
task_finder_data_t find_data;
|
||||
char task_title[PATH_MAX_LENGTH];
|
||||
retro_task_t *task = NULL;
|
||||
manual_scan_handle_t *manual_scan = (manual_scan_handle_t*)
|
||||
calloc(1, sizeof(manual_scan_handle_t));
|
||||
manual_scan_handle_t *manual_scan = NULL;
|
||||
|
||||
task_title[0] = '\0';
|
||||
|
||||
/* Sanity check */
|
||||
if (!playlist_config ||
|
||||
string_is_empty(playlist_directory) ||
|
||||
!manual_scan)
|
||||
goto error;
|
||||
if ( !playlist_config
|
||||
|| string_is_empty(playlist_directory))
|
||||
return false;
|
||||
|
||||
if (!(manual_scan = (manual_scan_handle_t*)
|
||||
calloc(1, sizeof(manual_scan_handle_t))))
|
||||
return false;
|
||||
|
||||
/* Configure handle */
|
||||
manual_scan->task_config = NULL;
|
||||
@ -563,21 +556,19 @@ bool task_push_manual_content_scan(
|
||||
manual_scan->playlist_index = 0;
|
||||
manual_scan->content_list_size = 0;
|
||||
manual_scan->content_list_index = 0;
|
||||
manual_scan->m3u_list = string_list_new();
|
||||
manual_scan->m3u_index = 0;
|
||||
manual_scan->status = MANUAL_SCAN_BEGIN;
|
||||
manual_scan->m3u_index = 0;
|
||||
manual_scan->m3u_list = string_list_new();
|
||||
|
||||
if (!manual_scan->m3u_list)
|
||||
goto error;
|
||||
|
||||
/* > Get current manual content scan configuration */
|
||||
manual_scan->task_config = (manual_content_scan_task_config_t*)
|
||||
calloc(1, sizeof(manual_content_scan_task_config_t));
|
||||
|
||||
if (!manual_scan->task_config)
|
||||
if (!(manual_scan->task_config = (manual_content_scan_task_config_t*)
|
||||
calloc(1, sizeof(manual_content_scan_task_config_t))))
|
||||
goto error;
|
||||
|
||||
if (!manual_content_scan_get_task_config(
|
||||
if ( !manual_content_scan_get_task_config(
|
||||
manual_scan->task_config, playlist_directory))
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
@ -605,9 +596,7 @@ bool task_push_manual_content_scan(
|
||||
goto error;
|
||||
|
||||
/* Create task */
|
||||
task = task_init();
|
||||
|
||||
if (!task)
|
||||
if (!(task = task_init()))
|
||||
goto error;
|
||||
|
||||
/* > Get task title */
|
||||
@ -632,14 +621,6 @@ bool task_push_manual_content_scan(
|
||||
return true;
|
||||
|
||||
error:
|
||||
|
||||
/* Clean up task */
|
||||
if (task)
|
||||
{
|
||||
free(task);
|
||||
task = NULL;
|
||||
}
|
||||
|
||||
/* Clean up handle */
|
||||
free_manual_content_scan_handle(manual_scan);
|
||||
manual_scan = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user