SDL_ENUMERATESTORAGEDIRECTORY(3)

✨ SDL_EnumerateStorageDirectory(3) ✨

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual πŸ’– this one lives in SDL_EnumerateStorageDirectory(3) and it's genuinely so useful, come sit with me.


πŸŽ€ NAME πŸŽ€

SDL_EnumerateStorageDirectory β€” Enumerate a directory in a storage container through a callback function.

like, you wanna peek inside a folder that lives in a storage container, and you want each lil entry handed to you one at a time through a callback? yeah. that's the whole vibe. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_storage.h>

bool SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);

no cap, that's the whole signature. copy it exactly, she's precise πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This function provides every directory entry through an app-provided callback, called once for each directory entry, until all results have been provided or the callback returns either SDL_ENUM_SUCCESS or SDL_ENUM_FAILURE.

so like… the callback keeps getting pinged, entry by entry, and it stops early if the callback says SDL_ENUM_SUCCESS or SDL_ENUM_FAILURE. it's giving very "we go until we're done or you tell me to stop" energy ✨

This will return false if there was a system problem in general, or if a callback returns SDL_ENUM_FAILURE. A successful return means a callback returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries were enumerated.

translation bestie: false = something broke system-wise, or your callback hit SDL_ENUM_FAILURE. true = either your callback returned SDL_ENUM_SUCCESS and stopped the whole thing early, or every single entry got enumerated. both are wins 🫢

If path is NULL, this is treated as a request to enumerate the root of the storage container's tree. An empty string also works for this.

yes literally, NULL or an empty string both mean "gimme the root of the tree". iconic, honestly 🌳


πŸ’– FUNCTION PARAMETERS πŸ’–

  • storage β€” a storage container. the whole point, the main character πŸŽ€
  • path β€” the path of the directory to enumerate, or NULL for the root. (NULL and "" are both root, remember!)
  • callback β€” a function that is called for each entry in the directory. your lil per-entry notifier πŸ“£
  • userdata β€” a pointer that is passed to callback. your lil care package that rides along for the journey πŸ’Œ

⭐ RETURN VALUE ⭐

Returns true on success or false on failure; call SDL_GetError() for more information.

so if it's false, go ask SDL_GetError() what's wrong, she always knows 😭


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0.

(if you're on something older than 3.2.0, this one's not for you yet, no cap πŸ™ˆ)


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page bestie, you ate it πŸ’…

Simple Directmedia Layer β€” SDL 3.4.18 β€” mwah, sending you the SDL_EnumerateStorageDirectory(3) energy, go slay your directory enumeration πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from