SDL: Removed the reserved parameter from SDL_EnumerateDirectoryCallback

From 7a088527c190e614ae86fa743ae20eebcdd59318 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 16 Mar 2024 09:18:32 -0700
Subject: [PATCH] Removed the reserved parameter from
 SDL_EnumerateDirectoryCallback

If someone needs to, say, include an SDL_Storage object, they can simply point userdata at a structure that includes the the storage and any other data needed in enumeration.
---
 include/SDL3/SDL_filesystem.h         | 4 ++--
 src/filesystem/dummy/SDL_sysfsops.c   | 2 +-
 src/filesystem/posix/SDL_sysfsops.c   | 4 ++--
 src/filesystem/windows/SDL_sysfsops.c | 8 ++++----
 test/testfilesystem.c                 | 2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/SDL3/SDL_filesystem.h b/include/SDL3/SDL_filesystem.h
index 75e71bf9737ea..1d49be7df7427 100644
--- a/include/SDL3/SDL_filesystem.h
+++ b/include/SDL3/SDL_filesystem.h
@@ -269,8 +269,8 @@ typedef struct SDL_PathInfo
  */
 extern DECLSPEC int SDLCALL SDL_CreateDirectory(const char *path);
 
-/* Callback for filesystem enumeration. Return 1 to keep enumerating, 0 to stop enumerating (no error), -1 to stop enumerating and report an error. "origdir" is the directory being enumerated, "fname" is the enumerated entry. */
-typedef int (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, void *reserved, const char *origdir, const char *fname);
+/* Callback for directory enumeration. Return 1 to keep enumerating, 0 to stop enumerating (no error), -1 to stop enumerating and report an error. `dirname` is the directory being enumerated, `fname` is the enumerated entry. */
+typedef int (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, const char *dirname, const char *fname);
 
 /**
  * Enumerate a directory.
diff --git a/src/filesystem/dummy/SDL_sysfsops.c b/src/filesystem/dummy/SDL_sysfsops.c
index 3e014722db2ab..5ad0663982aec 100644
--- a/src/filesystem/dummy/SDL_sysfsops.c
+++ b/src/filesystem/dummy/SDL_sysfsops.c
@@ -50,5 +50,5 @@ int SDL_SYS_FSstat(const char *fullpath, SDL_PathInfo *st)
     return SDL_Unsupported();
 }
 
-#endif
+#endif // SDL_FSOPS_DUMMY
 
diff --git a/src/filesystem/posix/SDL_sysfsops.c b/src/filesystem/posix/SDL_sysfsops.c
index 69e42d6eefb10..1f8ff58468c1a 100644
--- a/src/filesystem/posix/SDL_sysfsops.c
+++ b/src/filesystem/posix/SDL_sysfsops.c
@@ -47,7 +47,7 @@ int SDL_SYS_FSenumerate(const char *fullpath, const char *dirname, SDL_Enumerate
         if ((SDL_strcmp(name, ".") == 0) || (SDL_strcmp(name, "..") == 0)) {
             continue;
         }
-        retval = cb(userdata, NULL, dirname, name);
+        retval = cb(userdata, dirname, name);
     }
 
     closedir(dir);
@@ -134,5 +134,5 @@ int SDL_SYS_FSstat(const char *fullpath, SDL_PathInfo *info)
     return 0;
 }
 
-#endif
+#endif // SDL_FSOPS_POSIX
 
diff --git a/src/filesystem/windows/SDL_sysfsops.c b/src/filesystem/windows/SDL_sysfsops.c
index 571c83eb138b5..b18fc580eba2e 100644
--- a/src/filesystem/windows/SDL_sysfsops.c
+++ b/src/filesystem/windows/SDL_sysfsops.c
@@ -35,7 +35,7 @@ int SDL_SYS_FSenumerate(const char *fullpath, const char *dirname, SDL_Enumerate
         for (int i = 'A'; (retval == 1) && (i <= 'Z'); i++) {
             if (drives & (1 << (i - 'A'))) {
                 name[0] = (char) i;
-                retval = cb(userdata, NULL, dirname, name);
+                retval = cb(userdata, dirname, name);
             }
         }
     } else {
@@ -49,7 +49,7 @@ int SDL_SYS_FSenumerate(const char *fullpath, const char *dirname, SDL_Enumerate
         // filename element at the end of the path string, so always tack on a "\\*" to get everything, and
         // also prevent any wildcards inserted by the app from being respected.
         SDL_snprintf(pattern, patternlen, "%s\\*", fullpath);
-    
+
         WCHAR *wpattern = WIN_UTF8ToString(pattern);
         SDL_free(pattern);
         if (!wpattern) {
@@ -76,7 +76,7 @@ int SDL_SYS_FSenumerate(const char *fullpath, const char *dirname, SDL_Enumerate
             if (!utf8fn) {
                 retval = -1;
             } else {
-                retval = cb(userdata, NULL, dirname, utf8fn);
+                retval = cb(userdata, dirname, utf8fn);
                 SDL_free(utf8fn);
             }
         } while ((retval == 1) && (FindNextFileW(dir, &entw) != 0));
@@ -184,5 +184,5 @@ int SDL_SYS_FSstat(const char *fullpath, SDL_PathInfo *info)
     return 1;
 }
 
-#endif
+#endif // SDL_FSOPS_WINDOWS
 
diff --git a/test/testfilesystem.c b/test/testfilesystem.c
index 35f99c8674284..5bd031427b411 100644
--- a/test/testfilesystem.c
+++ b/test/testfilesystem.c
@@ -15,7 +15,7 @@
 #include <SDL3/SDL_main.h>
 #include <SDL3/SDL_test.h>
 
-static int SDLCALL enum_callback(void *userdata, void *reserved, const char *origdir, const char *fname)
+static int SDLCALL enum_callback(void *userdata, const char *origdir, const char *fname)
 {
     SDL_PathInfo info;
     char *fullpath = NULL;