diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index aa221c888c..0b716e6e56 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -103,6 +103,7 @@ struct RDIR *retro_opendir(const char *name) char path_buf[1024]; char *path_local = NULL; wchar_t *path_wide = NULL; + unsigned path_len; #endif struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir)); @@ -114,7 +115,13 @@ struct RDIR *retro_opendir(const char *name) (void)path_local; path_buf[0] = '\0'; - snprintf(path_buf, sizeof(path_buf), "%s\\*", name); + path_len = strlen(name); + + /* Non-NT platforms don't like extra slashes in the path */ + if (name[path_len - 1] == '\\') + snprintf(path_buf, sizeof(path_buf), "%s*", name); + else + snprintf(path_buf, sizeof(path_buf), "%s\\*", name); #if defined(LEGACY_WIN32) path_local = utf8_to_local_string_alloc(path_buf); rdir->directory = FindFirstFile(path_local, &rdir->entry);