From 14edb21aec281dd0c8d07cef6683796c001aeeab Mon Sep 17 00:00:00 2001
From: John Alanbrook <[EMAIL REDACTED]>
Date: Thu, 30 Jan 2025 13:15:25 -0600
Subject: [PATCH] check for backslashes as well as the forward slash
---
src/filesystem/SDL_filesystem.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/filesystem/SDL_filesystem.c b/src/filesystem/SDL_filesystem.c
index 28388517c4978..75556524d93da 100644
--- a/src/filesystem/SDL_filesystem.c
+++ b/src/filesystem/SDL_filesystem.c
@@ -363,16 +363,16 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
return NULL;
}
- // if path ends with any '/', chop them off, so we don't confuse the pattern matcher later.
+ // if path ends with any slash, chop them off, so we don't confuse the pattern matcher later.
char *pathcpy = NULL;
size_t pathlen = SDL_strlen(path);
- if ((pathlen > 1) && (path[pathlen-1] == '/')) {
+ if ((pathlen > 1) && ((path[pathlen-1] == '/') || (path[pathlen-1] == '\\'))) {
pathcpy = SDL_strdup(path);
if (!pathcpy) {
return NULL;
}
char *ptr = &pathcpy[pathlen-1];
- while ((ptr >= pathcpy) && (*ptr == '/')) {
+ while ((ptr >= pathcpy) && ((*ptr == '/') || (*ptr == '\\'))) {
*(ptr--) = '\0';
}
path = pathcpy;