filesystem: SDL_SYS_EnumerateDirectory() now returns bool.

This commit is contained in:
Ryan C. Gordon 2024-09-26 16:35:15 -04:00
parent 86ea283904
commit 38f971bac5
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
5 changed files with 8 additions and 12 deletions

View File

@ -69,10 +69,7 @@ bool SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback cal
} else if (!callback) {
return SDL_InvalidParamError("callback");
}
if (SDL_SYS_EnumerateDirectory(path, path, callback, userdata) < 0) {
return false;
}
return true;
return SDL_SYS_EnumerateDirectory(path, path, callback, userdata);
}
bool SDL_GetPathInfo(const char *path, SDL_PathInfo *info)

View File

@ -27,7 +27,7 @@ extern char *SDL_SYS_GetBasePath(void);
extern char *SDL_SYS_GetPrefPath(const char *org, const char *app);
extern char *SDL_SYS_GetUserFolder(SDL_Folder folder);
extern int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata);
extern bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata);
extern bool SDL_SYS_RemovePath(const char *path);
extern bool SDL_SYS_RenamePath(const char *oldpath, const char *newpath);
extern bool SDL_SYS_CopyFile(const char *oldpath, const char *newpath);

View File

@ -28,10 +28,9 @@
#include "../SDL_sysfilesystem.h"
int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata)
bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata)
{
SDL_Unsupported();
return -1;
return SDL_Unsupported();
}
bool SDL_SYS_RemovePath(const char *path)

View File

@ -34,7 +34,7 @@
#include <dirent.h>
#include <sys/stat.h>
int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata)
bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata)
{
int result = 1;
@ -56,7 +56,7 @@ int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enumer
closedir(dir);
return result;
return (result >= 0);
}
bool SDL_SYS_RemovePath(const char *path)

View File

@ -29,7 +29,7 @@
#include "../../core/windows/SDL_windows.h"
#include "../SDL_sysfilesystem.h"
int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata)
bool SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_EnumerateDirectoryCallback cb, void *userdata)
{
int result = 1;
if (*path == '\0') { // if empty (completely at the root), we need to enumerate drive letters.
@ -88,7 +88,7 @@ int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enumer
FindClose(dir);
}
return result;
return (result >= 0);
}
bool SDL_SYS_RemovePath(const char *path)