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

@@ -20,14 +20,7 @@ static SDL_EnumerationResult SDLCALL enum_callback(void *userdata, const char *o
SDL_PathInfo info;
char *fullpath = NULL;
/* you can use '/' for a path separator on Windows, but to make the log output look correct, we'll #ifdef this... */
#ifdef SDL_PLATFORM_WINDOWS
const char *pathsep = "\\";
#else
const char *pathsep = "/";
#endif
if (SDL_asprintf(&fullpath, "%s%s%s", origdir, *origdir ? pathsep : "", fname) < 0) {
if (SDL_asprintf(&fullpath, "%s%s", origdir, fname) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
return SDL_ENUM_FAILURE;
}