scanner: allow matching archives by member

This allows more flexible detection of content packaged as multiple
compressed files (e.g. MAME).
This commit is contained in:
Brian Koropoff 2017-11-08 16:59:52 -08:00
parent 94aa2cd08a
commit b668193923
3 changed files with 57 additions and 1 deletions

View File

@ -389,6 +389,10 @@ static core_info_list_t *core_info_list_new(const char *path)
&tmp_bool))
core_info[i].supports_no_game = tmp_bool;
if (config_get_bool(conf, "database_match_archive_member",
&tmp_bool))
core_info[i].database_match_archive_member = tmp_bool;
core_info[i].config_data = conf;
}
else
@ -823,6 +827,46 @@ size_t core_info_list_num_info_files(core_info_list_t *core_info_list)
return num;
}
bool core_info_database_match_archive_member(const char *database_path)
{
char *database = NULL;
const char *new_path = path_basename(database_path);
if (string_is_empty(new_path))
return false;
database = strdup(new_path);
if (string_is_empty(database))
goto error;
path_remove_extension(database);
if (core_info_curr_list)
{
size_t i;
for (i = 0; i < core_info_curr_list->count; i++)
{
const core_info_t *info = &core_info_curr_list->list[i];
if (!info->database_match_archive_member)
continue;
if (!string_list_find_elem(info->databases_list, database))
continue;
free(database);
return true;
}
}
error:
if (database)
free(database);
return false;
}
bool core_info_database_supports_content_path(const char *database_path, const char *path)
{
char *database = NULL;

View File

@ -38,6 +38,7 @@ typedef struct
typedef struct
{
bool supports_no_game;
bool database_match_archive_member;
size_t firmware_count;
char *path;
void *config_data;
@ -120,6 +121,8 @@ bool core_info_load(core_info_ctx_find_t *info);
bool core_info_database_supports_content_path(const char *database_path, const char *path);
bool core_info_database_match_archive_member(const char *database_path);
bool core_info_unsupported_content_path(const char *path);
RETRO_END_DECLS

View File

@ -797,6 +797,7 @@ static int database_info_list_iterate_found_match(
database_info_get_current_element_name(db);
database_info_t *db_info_entry =
&db_state->info->list[db_state->entry_index];
char *hash;
db_crc[0] = '\0';
db_playlist_path[0] = '\0';
@ -827,6 +828,11 @@ static int database_info_list_iterate_found_match(
entry_path_str, archive_name,
'#', PATH_MAX_LENGTH * sizeof(char));
if (core_info_database_match_archive_member(
db_state->list->elems[db_state->list_index].data) &&
(hash = strchr(entry_path_str, '#')))
*hash = '\0';
#if 0
RARCH_LOG("Found match in database !\n");
@ -900,7 +906,10 @@ static int task_database_iterate_crc_lookup(
query[0] = '\0';
/* don't scan files that can't be in this database */
if (!core_info_database_supports_content_path(
if (!(path_contains_compressed_file(name) &&
core_info_database_match_archive_member(
db_state->list->elems[db_state->list_index].data)) &&
!core_info_database_supports_content_path(
db_state->list->elems[db_state->list_index].data, name))
return database_info_list_iterate_next(db_state);