mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-06 01:46:25 +00:00
check for backslashes as well as the forward slash
This commit is contained in:

committed by
Sam Lantinga

parent
50b8c6cdfb
commit
14edb21aec
@@ -363,16 +363,16 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
|
|||||||
return NULL;
|
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;
|
char *pathcpy = NULL;
|
||||||
size_t pathlen = SDL_strlen(path);
|
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);
|
pathcpy = SDL_strdup(path);
|
||||||
if (!pathcpy) {
|
if (!pathcpy) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
char *ptr = &pathcpy[pathlen-1];
|
char *ptr = &pathcpy[pathlen-1];
|
||||||
while ((ptr >= pathcpy) && (*ptr == '/')) {
|
while ((ptr >= pathcpy) && ((*ptr == '/') || (*ptr == '\\'))) {
|
||||||
*(ptr--) = '\0';
|
*(ptr--) = '\0';
|
||||||
}
|
}
|
||||||
path = pathcpy;
|
path = pathcpy;
|
||||||
|
Reference in New Issue
Block a user