mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
strstr produces lot of false matches, path_remote_extension didn't seem to work so I included my own version
This commit is contained in:
parent
d1e554ac2e
commit
8f766574d3
@ -88,6 +88,23 @@ static void netplay_crc_scan_callback(void *task_data,
|
||||
free(state);
|
||||
}
|
||||
|
||||
char *filename_remove_ext(const char* str)
|
||||
{
|
||||
char *ret;
|
||||
char *lastdot;
|
||||
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
if ((ret = malloc (strlen (str) + 1)) == NULL)
|
||||
return NULL;
|
||||
strcpy (ret, str);
|
||||
lastdot = strrchr (ret, '.');
|
||||
if (lastdot != NULL)
|
||||
*lastdot = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
{
|
||||
size_t i, j;
|
||||
@ -127,7 +144,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
{
|
||||
if (string_is_equal(playlist->entries[j].crc32, state->crc))
|
||||
{
|
||||
printf("CRC Match %s\n", state->crc);
|
||||
printf("CRC Match %s\n", playlist->entries[j].crc32);
|
||||
strlcpy(state->path, playlist->entries[j].path, sizeof(state->path));
|
||||
state->found = true;
|
||||
task_set_data(task, state);
|
||||
@ -160,10 +177,14 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
|
||||
for (j = 0; j < playlist->size; j++)
|
||||
{
|
||||
/*printf("State: %s Entry: %s\n", state->path, playlist->entries[j].path);*/
|
||||
if (strstr(playlist->entries[j].path, state->path))
|
||||
const char* buf = path_basename(playlist->entries[j].path);
|
||||
char* entry = filename_remove_ext(buf);
|
||||
#if 1
|
||||
printf("%s %s\n", entry, state->path);
|
||||
#endif
|
||||
if (string_is_equal(entry, state->path))
|
||||
{
|
||||
printf("Filename Match %s\n", state->path);
|
||||
printf("Filename Match %s\n", playlist->entries[j].path);
|
||||
strlcpy(state->path, playlist->entries[j].path, sizeof(state->path));
|
||||
state->found = true;
|
||||
task_set_data(task, state);
|
||||
@ -172,8 +193,10 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
task_set_finished(task, true);
|
||||
string_list_free(state->lpl_list);
|
||||
free(playlist);
|
||||
free(entry);
|
||||
return;
|
||||
}
|
||||
free(entry);
|
||||
|
||||
task_set_progress(task, (int)(j/playlist->size*100.0));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user