filesystem: SDL_EnumerateDirectory() gives dirs with path seperators appended.

Fixes #11065.
Fixes #11427.
This commit is contained in:
Ryan C. Gordon
2025-01-15 17:03:01 -05:00
parent e98ee9bb04
commit 87e1b0eb89
5 changed files with 54 additions and 29 deletions

View File

@@ -307,7 +307,7 @@ static SDL_EnumerationResult SDLCALL GlobDirectoryCallback(void *userdata, const
// !!! FIXME: and only casefold the new pieces instead of allocating and folding full paths for all of this.
char *fullpath = NULL;
if (SDL_asprintf(&fullpath, "%s/%s", dirname, fname) < 0) {
if (SDL_asprintf(&fullpath, "%s%s", dirname, fname) < 0) {
return SDL_ENUM_FAILURE;
}
@@ -417,7 +417,8 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
data.enumerator = enumerator;
data.getpathinfo = getpathinfo;
data.fsuserdata = userdata;
data.basedirlen = SDL_strlen(path) + 1; // +1 for the '/' we'll be adding.
data.basedirlen = *path ? (SDL_strlen(path) + 1) : 0; // +1 for the '/' we'll be adding.
char **result = NULL;
if (data.enumerator(path, GlobDirectoryCallback, &data, data.fsuserdata)) {