SDL_ENUMERATEDIRECTORYCALLBACK(3type)

πŸ’– SDL_EnumerateDirectoryCallback β€” the SDL3 DATATYPES glow-up πŸ’–

okay so bestie, welcome to the <SDL_Enumera...oryCallback>(3type) page, straight out of the SDL3 DATATYPES section. this one's short, sweet, and lowkey iconic: it's the callback you hand over when you want SDL to walk a directory for you and ping you for every single thing it finds. let's get into it πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_filesystem.h>

typedef SDL_EnumerationResult (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, const char *dirname, const char *fname);

that's the whole signature, no notes, she's perfect πŸ’…


🌸 DESCRIPTION 🌸

so here's the vibe: SDL is gonna keep feeding directory entries to your callback. it does not stop until one of two things happens β€” either every single entry has been handed over, or your callback says "okay bestie, we're done here" through its return value. that's it, that's the whole relationship πŸ¦‹

  • returning SDL_ENUM_CONTINUE means "keep going, I'm not done yet" β€” enumeration proceeds and the callback gets called again with more entries.
  • returning SDL_ENUM_SUCCESS or SDL_ENUM_FAILURE terminates the enumeration early, and whichever one you picked also dictates the return value of the enumeration function itself. so like, you're literally steering the whole ship here πŸ‘‘

and a lil detail that matters: dirname is guaranteed to end with a path separator β€” that's '\\' on Windows and '/' on most other platforms. no cap, it's always gonna be there, so you can trust it 🌈


🧚 FUNCTION PARAMETERS 🧚

  • userdata β€” an app-controlled pointer that gets passed straight to the callback. it's yours, do whatever you want with it πŸ’œ
  • dirname β€” the directory that is being enumerated.
  • fname β€” the next entry in the enumeration. one at a time, bestie, we're being methodical πŸ“

⭐ RETURN VALUE ⭐

Returns how the enumeration should proceed. that's the whole deal β€” you're the main character deciding whether the walk continues or wraps up ✨


πŸ‘‘ AVAILABILITY πŸ‘‘

This datatype is available since SDL 3.2.0. so if you're on anything older, sorry bestie, you're out of luck 😭


πŸ”₯ SEE ALSO πŸ”₯


ngl, this is one of those pages where the whole personality is in the return value. don't sleep on SDL_ENUM_CONTINUE β€” it's doing a lot of heavy lifting 🫢

and that's a wrap!! this page came to you from Simple Directmedia Layer, version SDL 3.4.18 β€” mwah, sending you off with the date it was born, stay slay, go enumerate some directories πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from