mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
(playlist.c) Cleanups
This commit is contained in:
parent
3ae8e35d0e
commit
ef0672f80b
131
playlist.c
131
playlist.c
@ -255,53 +255,53 @@ static void playlist_path_id_free(playlist_path_id_t *path_id)
|
|||||||
|
|
||||||
static playlist_path_id_t *playlist_path_id_init(const char *path)
|
static playlist_path_id_t *playlist_path_id_init(const char *path)
|
||||||
{
|
{
|
||||||
playlist_path_id_t *path_id = (playlist_path_id_t*)malloc(sizeof(*path_id));
|
playlist_path_id_t *path_id = (playlist_path_id_t*)malloc(sizeof(*path_id));
|
||||||
const char *archive_delim = NULL;
|
|
||||||
char real_path[PATH_MAX_LENGTH];
|
|
||||||
|
|
||||||
if (!path_id)
|
if (!path_id)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path_id->real_path = NULL;
|
path_id->real_path = NULL;
|
||||||
path_id->archive_path = NULL;
|
path_id->archive_path = NULL;
|
||||||
path_id->real_path_hash = 0;
|
path_id->real_path_hash = 0;
|
||||||
path_id->archive_path_hash = 0;
|
path_id->archive_path_hash = 0;
|
||||||
path_id->is_archive = false;
|
path_id->is_archive = false;
|
||||||
path_id->is_in_archive = false;
|
path_id->is_in_archive = false;
|
||||||
|
|
||||||
if (string_is_empty(path))
|
if (!string_is_empty(path))
|
||||||
return path_id;
|
|
||||||
|
|
||||||
/* Get real path */
|
|
||||||
strlcpy(real_path, path, sizeof(real_path));
|
|
||||||
playlist_resolve_path(PLAYLIST_SAVE, false, real_path,
|
|
||||||
sizeof(real_path));
|
|
||||||
|
|
||||||
path_id->real_path = strdup(real_path);
|
|
||||||
path_id->real_path_hash = playlist_path_hash(real_path);
|
|
||||||
|
|
||||||
/* Check archive status */
|
|
||||||
path_id->is_archive = path_is_compressed_file(real_path);
|
|
||||||
archive_delim = path_get_archive_delim(real_path);
|
|
||||||
|
|
||||||
/* If path refers to a file inside an archive,
|
|
||||||
* extract the path of the parent archive */
|
|
||||||
if (archive_delim)
|
|
||||||
{
|
{
|
||||||
char archive_path[PATH_MAX_LENGTH];
|
char real_path[PATH_MAX_LENGTH];
|
||||||
size_t len = (1 + archive_delim - real_path);
|
const char *archive_delim = NULL;
|
||||||
if (len >= PATH_MAX_LENGTH)
|
/* Get real path */
|
||||||
len = PATH_MAX_LENGTH;
|
strlcpy(real_path, path, sizeof(real_path));
|
||||||
strlcpy(archive_path, real_path, len * sizeof(char));
|
playlist_resolve_path(PLAYLIST_SAVE, false, real_path,
|
||||||
|
sizeof(real_path));
|
||||||
|
|
||||||
path_id->archive_path = strdup(archive_path);
|
path_id->real_path = strdup(real_path);
|
||||||
path_id->archive_path_hash = playlist_path_hash(archive_path);
|
path_id->real_path_hash = playlist_path_hash(real_path);
|
||||||
path_id->is_in_archive = true;
|
|
||||||
}
|
/* Check archive status */
|
||||||
else if (path_id->is_archive)
|
path_id->is_archive = path_is_compressed_file(real_path);
|
||||||
{
|
archive_delim = path_get_archive_delim(real_path);
|
||||||
path_id->archive_path = path_id->real_path;
|
|
||||||
path_id->archive_path_hash = path_id->real_path_hash;
|
/* If path refers to a file inside an archive,
|
||||||
|
* extract the path of the parent archive */
|
||||||
|
if (archive_delim)
|
||||||
|
{
|
||||||
|
char archive_path[PATH_MAX_LENGTH];
|
||||||
|
size_t len = (1 + archive_delim - real_path);
|
||||||
|
if (len >= PATH_MAX_LENGTH)
|
||||||
|
len = PATH_MAX_LENGTH;
|
||||||
|
strlcpy(archive_path, real_path, len * sizeof(char));
|
||||||
|
|
||||||
|
path_id->archive_path = strdup(archive_path);
|
||||||
|
path_id->archive_path_hash = playlist_path_hash(archive_path);
|
||||||
|
path_id->is_in_archive = true;
|
||||||
|
}
|
||||||
|
else if (path_id->is_archive)
|
||||||
|
{
|
||||||
|
path_id->archive_path = path_id->real_path;
|
||||||
|
path_id->archive_path_hash = path_id->real_path_hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return path_id;
|
return path_id;
|
||||||
@ -420,8 +420,7 @@ static bool playlist_path_matches_entry(playlist_path_id_t *path_id,
|
|||||||
/* Check whether entry contains a path ID cache */
|
/* Check whether entry contains a path ID cache */
|
||||||
if (!entry->path_id)
|
if (!entry->path_id)
|
||||||
{
|
{
|
||||||
entry->path_id = playlist_path_id_init(entry->path);
|
if (!(entry->path_id = playlist_path_id_init(entry->path)))
|
||||||
if (!entry->path_id)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3055,10 +3054,10 @@ bool playlist_entries_are_equal(
|
|||||||
if (!entry_a || !entry_b || !config)
|
if (!entry_a || !entry_b || !config)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (string_is_empty(entry_a->path) &&
|
if ( string_is_empty(entry_a->path)
|
||||||
string_is_empty(entry_a->core_path) &&
|
&& string_is_empty(entry_a->core_path)
|
||||||
string_is_empty(entry_b->path) &&
|
&& string_is_empty(entry_b->path)
|
||||||
string_is_empty(entry_b->core_path))
|
&& string_is_empty(entry_b->core_path))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Check content paths */
|
/* Check content paths */
|
||||||
@ -3253,7 +3252,8 @@ bool playlist_scan_refresh_enabled(playlist_t *playlist)
|
|||||||
return !string_is_empty(playlist->scan_record.content_dir);
|
return !string_is_empty(playlist->scan_record.content_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void playlist_set_default_core_path(playlist_t *playlist, const char *core_path)
|
void playlist_set_default_core_path(playlist_t *playlist,
|
||||||
|
const char *core_path)
|
||||||
{
|
{
|
||||||
char real_core_path[PATH_MAX_LENGTH];
|
char real_core_path[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
@ -3274,8 +3274,8 @@ void playlist_set_default_core_path(playlist_t *playlist, const char *core_path)
|
|||||||
{
|
{
|
||||||
if (playlist->default_core_path)
|
if (playlist->default_core_path)
|
||||||
free(playlist->default_core_path);
|
free(playlist->default_core_path);
|
||||||
playlist->default_core_path = strdup(real_core_path);
|
playlist->default_core_path = strdup(real_core_path);
|
||||||
playlist->modified = true;
|
playlist->modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3289,8 +3289,8 @@ void playlist_set_default_core_name(
|
|||||||
{
|
{
|
||||||
if (playlist->default_core_name)
|
if (playlist->default_core_name)
|
||||||
free(playlist->default_core_name);
|
free(playlist->default_core_name);
|
||||||
playlist->default_core_name = strdup(core_name);
|
playlist->default_core_name = strdup(core_name);
|
||||||
playlist->modified = true;
|
playlist->modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3300,7 +3300,7 @@ void playlist_set_label_display_mode(playlist_t *playlist,
|
|||||||
if (playlist && playlist->label_display_mode != label_display_mode)
|
if (playlist && playlist->label_display_mode != label_display_mode)
|
||||||
{
|
{
|
||||||
playlist->label_display_mode = label_display_mode;
|
playlist->label_display_mode = label_display_mode;
|
||||||
playlist->modified = true;
|
playlist->modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3379,9 +3379,9 @@ void playlist_set_scan_file_exts(playlist_t *playlist, const char *file_exts)
|
|||||||
/* Check whether string value has changed
|
/* Check whether string value has changed
|
||||||
* (note that a NULL or empty argument will
|
* (note that a NULL or empty argument will
|
||||||
* unset the playlist value) */
|
* unset the playlist value) */
|
||||||
if (( current_string_empty && !new_string_empty) ||
|
if ( ( current_string_empty && !new_string_empty)
|
||||||
(!current_string_empty && new_string_empty) ||
|
|| (!current_string_empty && new_string_empty)
|
||||||
!string_is_equal(playlist->scan_record.file_exts, file_exts))
|
|| !string_is_equal(playlist->scan_record.file_exts, file_exts))
|
||||||
playlist->modified = true;
|
playlist->modified = true;
|
||||||
else
|
else
|
||||||
return; /* Strings are identical; do nothing */
|
return; /* Strings are identical; do nothing */
|
||||||
@ -3459,13 +3459,12 @@ void playlist_set_scan_filter_dat_content(playlist_t *playlist, bool filter_dat_
|
|||||||
* other than DETECT) */
|
* other than DETECT) */
|
||||||
bool playlist_entry_has_core(const struct playlist_entry *entry)
|
bool playlist_entry_has_core(const struct playlist_entry *entry)
|
||||||
{
|
{
|
||||||
if (!entry ||
|
if ( !entry
|
||||||
string_is_empty(entry->core_path) ||
|
|| string_is_empty(entry->core_path)
|
||||||
string_is_empty(entry->core_name) ||
|
|| string_is_empty(entry->core_name)
|
||||||
string_is_equal(entry->core_path, FILE_PATH_DETECT) ||
|
|| string_is_equal(entry->core_path, FILE_PATH_DETECT)
|
||||||
string_is_equal(entry->core_name, FILE_PATH_DETECT))
|
|| string_is_equal(entry->core_name, FILE_PATH_DETECT))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3495,11 +3494,11 @@ core_info_t *playlist_get_default_core_info(playlist_t* playlist)
|
|||||||
{
|
{
|
||||||
core_info_t *core_info = NULL;
|
core_info_t *core_info = NULL;
|
||||||
|
|
||||||
if (!playlist ||
|
if ( !playlist
|
||||||
string_is_empty(playlist->default_core_path) ||
|
|| string_is_empty(playlist->default_core_path)
|
||||||
string_is_empty(playlist->default_core_name) ||
|
|| string_is_empty(playlist->default_core_name)
|
||||||
string_is_equal(playlist->default_core_path, FILE_PATH_DETECT) ||
|
|| string_is_equal(playlist->default_core_path, FILE_PATH_DETECT)
|
||||||
string_is_equal(playlist->default_core_name, FILE_PATH_DETECT))
|
|| string_is_equal(playlist->default_core_name, FILE_PATH_DETECT))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Search for associated core */
|
/* Search for associated core */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user