From a9ead799e698b2b58d054463e0ab63e100d2d8b1 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Mon, 14 Nov 2016 13:24:05 -0500 Subject: [PATCH 01/10] improve cross-platform support for thumbnail filenames The intention of this PR is to allow RetroArch playlists to display the 'prohibited' characters & \ / ? : < > : * | on the screen, while searching for matching thumbnail files that replace these problematic characters with an underscore. This step of the process is bolded in the flowchart below as #2 under 'Playlist display.' I don't normally work in C -- this change is a hack job. It did look like string_replace_substring could handle being daisy-chained so I thought I'd see if this could spark a productive conversation. Playlist generation: 1) Use hash values to match ROM files to known-good databases such as No-Intro. (exists) 2) Create playlist using 'display names' from the known-good databases (exists) Playlist display: 1) Read display name from the playlist file (exists) **2) Transform characters that are not cross-platform friendly into underscores to determine thumb filename (this PR)** 3) Look for a thumbnail file that matches this filename (exists) 4) Display the thumbnail image (exists) --- menu/drivers/xmb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 728e9d34fe..b66a95c424 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -861,8 +861,17 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) fill_pathname_join(xmb->thumbnail_file_path, xmb->thumbnail_file_path, xmb_thumbnails_ident(), sizeof(xmb->thumbnail_file_path)); - tmp = string_replace_substring(entry.path, "/", "-"); - + tmp = string_replace_substring(entry.path, "&", "_"); + tmp = string_replace_substring(entry.path, "\", "_"); + tmp = string_replace_substring(entry.path, "/", "_"); + tmp = string_replace_substring(entry.path, "?", "_"); + tmp = string_replace_substring(entry.path, ":", "_"); + tmp = string_replace_substring(entry.path, "<", "_"); + tmp = string_replace_substring(entry.path, ">", "_"); + tmp = string_replace_substring(entry.path, ":", "_"); + tmp = string_replace_substring(entry.path, "*", "_"); + tmp = string_replace_substring(entry.path, "|", "_"); + if (tmp) { char tmp_new[PATH_MAX_LENGTH]; From 06221da8a1c3e18ca6f8bd1c3cadc52f2e17f160 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 09:03:55 -0500 Subject: [PATCH 02/10] fix escape characters, remove dupe line, add comment --- menu/drivers/xmb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b66a95c424..3693192562 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -861,17 +861,19 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) fill_pathname_join(xmb->thumbnail_file_path, xmb->thumbnail_file_path, xmb_thumbnails_ident(), sizeof(xmb->thumbnail_file_path)); + /* Scrub characters that are not cross-platform safe from 'display name' in playlist and replace with underscore */ tmp = string_replace_substring(entry.path, "&", "_"); - tmp = string_replace_substring(entry.path, "\", "_"); + tmp = string_replace_substring(entry.path, "\\", "_"); tmp = string_replace_substring(entry.path, "/", "_"); - tmp = string_replace_substring(entry.path, "?", "_"); + tmp = string_replace_substring(entry.path, "\?", "_"); tmp = string_replace_substring(entry.path, ":", "_"); tmp = string_replace_substring(entry.path, "<", "_"); tmp = string_replace_substring(entry.path, ">", "_"); - tmp = string_replace_substring(entry.path, ":", "_"); tmp = string_replace_substring(entry.path, "*", "_"); tmp = string_replace_substring(entry.path, "|", "_"); - + + /* Look for thumbnail file with the scrubbed filename */ + if (tmp) { char tmp_new[PATH_MAX_LENGTH]; From d0f23fdddb62c15150ca5244bb11a611f5865ebf Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 09:05:33 -0500 Subject: [PATCH 03/10] Update xmb.c --- menu/drivers/xmb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 3693192562..b8c2cc5b33 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -866,7 +866,8 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) tmp = string_replace_substring(entry.path, "\\", "_"); tmp = string_replace_substring(entry.path, "/", "_"); tmp = string_replace_substring(entry.path, "\?", "_"); - tmp = string_replace_substring(entry.path, ":", "_"); + tmp = string_replace_substring(entry.path, ":", "_"); + tmp = string_replace_substring(entry.path, ";", "_"); tmp = string_replace_substring(entry.path, "<", "_"); tmp = string_replace_substring(entry.path, ">", "_"); tmp = string_replace_substring(entry.path, "*", "_"); From 096b31618386bfe2354c70ce849c8b88b80cc2ad Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 14:01:28 -0500 Subject: [PATCH 04/10] additional fixes per the PR discussion --- menu/drivers/xmb.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b8c2cc5b33..1043d4cdfe 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -862,16 +862,39 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) xmb_thumbnails_ident(), sizeof(xmb->thumbnail_file_path)); /* Scrub characters that are not cross-platform safe from 'display name' in playlist and replace with underscore */ - tmp = string_replace_substring(entry.path, "&", "_"); - tmp = string_replace_substring(entry.path, "\\", "_"); - tmp = string_replace_substring(entry.path, "/", "_"); - tmp = string_replace_substring(entry.path, "\?", "_"); - tmp = string_replace_substring(entry.path, ":", "_"); - tmp = string_replace_substring(entry.path, ";", "_"); - tmp = string_replace_substring(entry.path, "<", "_"); - tmp = string_replace_substring(entry.path, ">", "_"); - tmp = string_replace_substring(entry.path, "*", "_"); - tmp = string_replace_substring(entry.path, "|", "_"); + char *scrub_char_pointer = 0; + *tmp = *entry.path; + + while ((scrub_char_pointer = strchr (tmp, '&')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '\\')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '/')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '?')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, ':')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '`')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '<')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '>')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '*')) != NULL) { + *scrub_char_pointer = '_'; + } + while ((scrub_char_pointer = strchr (tmp, '_')) != NULL) { + *scrub_char_pointer = '_'; + } /* Look for thumbnail file with the scrubbed filename */ From 167a71635dc763549d43423128d93f7f7d399d4e Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 14:04:59 -0500 Subject: [PATCH 05/10] Update xmb.c --- menu/drivers/xmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1043d4cdfe..b990d47b70 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -892,7 +892,7 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) while ((scrub_char_pointer = strchr (tmp, '*')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '_')) != NULL) { + while ((scrub_char_pointer = strchr (tmp, '|')) != NULL) { *scrub_char_pointer = '_'; } From 08514679d56f6b9464d5eb0e5a6416aa1265936c Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 15:47:18 -0500 Subject: [PATCH 06/10] Update xmb.c --- menu/drivers/xmb.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b990d47b70..d386d554fb 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -863,36 +863,36 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) /* Scrub characters that are not cross-platform safe from 'display name' in playlist and replace with underscore */ char *scrub_char_pointer = 0; - *tmp = *entry.path; + tmp = strdup(entry.path); - while ((scrub_char_pointer = strchr (tmp, '&')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '&')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '\\')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '\\')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '/')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '/')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '?')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '?')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, ':')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, ':')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '`')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '`')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '<')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '<')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '>')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '>')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '*')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '*')) != NULL) { *scrub_char_pointer = '_'; } - while ((scrub_char_pointer = strchr (tmp, '|')) != NULL) { + while ((scrub_char_pointer = strchr(tmp, '|')) != NULL) { *scrub_char_pointer = '_'; } From 9d0e5c012e0b3027f42519d6e23c51020bd490b4 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 15:57:51 -0500 Subject: [PATCH 07/10] change thumbnail filename scrub to use strpbrk() --- menu/drivers/xmb.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d386d554fb..9b804b52ab 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -865,40 +865,13 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) char *scrub_char_pointer = 0; tmp = strdup(entry.path); - while ((scrub_char_pointer = strchr(tmp, '&')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '\\')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '/')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '?')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, ':')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '`')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '<')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '>')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '*')) != NULL) { - *scrub_char_pointer = '_'; - } - while ((scrub_char_pointer = strchr(tmp, '|')) != NULL) { + while(scrub_char_pointer = strpbrk(tmp, "&*/:`<>?\|")) + { *scrub_char_pointer = '_'; } /* Look for thumbnail file with the scrubbed filename */ - - if (tmp) + if (tmp) { char tmp_new[PATH_MAX_LENGTH]; From 1ad1598be29762cd7b02a9d81216ab27849607fc Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 15:58:18 -0500 Subject: [PATCH 08/10] Update xmb.c --- menu/drivers/xmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9b804b52ab..d9d922ebc4 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -865,7 +865,7 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) char *scrub_char_pointer = 0; tmp = strdup(entry.path); - while(scrub_char_pointer = strpbrk(tmp, "&*/:`<>?\|")) + while(scrub_char_pointer = strpbrk(tmp, "&*/:`<>?\\|")) { *scrub_char_pointer = '_'; } From 0d8c2aa1198bd3c7019e834383a319acc1015d59 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 16:48:29 -0500 Subject: [PATCH 09/10] improve description of thumb filename scrub, add parenthesis --- menu/drivers/xmb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d9d922ebc4..c9d60a3a91 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -861,16 +861,19 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) fill_pathname_join(xmb->thumbnail_file_path, xmb->thumbnail_file_path, xmb_thumbnails_ident(), sizeof(xmb->thumbnail_file_path)); - /* Scrub characters that are not cross-platform safe from 'display name' in playlist and replace with underscore */ + /* Scrub characters that are not cross-platform and/or violate the No-Intro filename standard: + * http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip + * Replace these characters in the entry name with underscores + */ char *scrub_char_pointer = 0; tmp = strdup(entry.path); - while(scrub_char_pointer = strpbrk(tmp, "&*/:`<>?\\|")) + while((scrub_char_pointer = strpbrk(tmp, "&*/:`<>?\\|"))) { *scrub_char_pointer = '_'; } - /* Look for thumbnail file with the scrubbed filename */ + /* Look for thumbnail file with this scrubbed filename */ if (tmp) { char tmp_new[PATH_MAX_LENGTH]; From e0deb20e300f05ca330faeedac8fb1d149d13706 Mon Sep 17 00:00:00 2001 From: markwkidd Date: Tue, 15 Nov 2016 16:54:35 -0500 Subject: [PATCH 10/10] Update xmb.c --- menu/drivers/xmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c9d60a3a91..53e9e8a395 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -865,7 +865,7 @@ static void xmb_update_thumbnail_path(void *data, unsigned i) * http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip * Replace these characters in the entry name with underscores */ - char *scrub_char_pointer = 0; + char *scrub_char_pointer = NULL; tmp = strdup(entry.path); while((scrub_char_pointer = strpbrk(tmp, "&*/:`<>?\\|")))