From 4d95af1ab3d8866926b70bfb03dc6fd632f2e39b Mon Sep 17 00:00:00 2001 From: entropy Date: Sun, 5 Feb 2012 06:38:10 +0000 Subject: [PATCH] Allow installation of games with titles containing illegal filename characters --- source/loader/wbfs_ext.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/loader/wbfs_ext.c b/source/loader/wbfs_ext.c index fb8a46b7..af0ef2e8 100644 --- a/source/loader/wbfs_ext.c +++ b/source/loader/wbfs_ext.c @@ -174,6 +174,10 @@ s32 WBFS_Ext_AddGame(progress_callback_t spinner, void *spinner_data) { struct discHdr header ATTRIBUTE_ALIGN(32); + char *illegal = "\"*/:<>?\\|"; + char *cp; + char *cleantitle; + char folder[MAX_FAT_PATH]; bzero(folder, MAX_FAT_PATH); @@ -181,7 +185,11 @@ s32 WBFS_Ext_AddGame(progress_callback_t spinner, void *spinner_data) bzero(gamepath, MAX_FAT_PATH); Disc_ReadHeader(&header); - snprintf(folder, sizeof(folder), "%s%s/%s [%s]", wbfs_fs_drive, wbfs_ext_dir, header.title, header.id); + asprintf(&cleantitle, header.title); + for (cp = strpbrk(cleantitle, illegal); cp; cp = strpbrk(cp, illegal)) + *cp = '_'; + snprintf(folder, sizeof(folder), "%s%s/%s [%s]", wbfs_fs_drive, wbfs_ext_dir, cleantitle, header.id); + free(cleantitle); makedir((char *)folder); snprintf(gamepath, sizeof(gamepath), "%s/%s.wbfs", folder, header.id); @@ -243,4 +251,4 @@ s32 WBFS_Ext_DVD_Size(u64 *comp_size, u64 *real_size) *real_size = (u64)(part->wii_sec_sz) * last_sec; return 0; -} \ No newline at end of file +}