You can pass NULL to SDL_GetPathInfo() and SDL_GetStoragePathInfo() to test for the existence of a file.

This commit is contained in:
Sam Lantinga
2024-03-18 08:43:22 -07:00
parent ebb6582534
commit 92d01ef12a
4 changed files with 22 additions and 8 deletions

View File

@@ -93,10 +93,16 @@ int SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback call
int SDL_GetPathInfo(const char *path, SDL_PathInfo *info)
{
SDL_PathInfo dummy;
if (!info) {
info = &dummy;
}
SDL_zerop(info);
if (!path) {
return SDL_InvalidParamError("path");
} else if (!info) {
return SDL_InvalidParamError("info");
}
return SDL_SYS_GetPathInfo(path, info);
}