SDL_ReadStorageFile(3)

πŸ’Ύ SDL_ReadStorageFile(3) πŸ’Ύ

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_ReadStorageFile and honestly? it's giving "just grab the file already." 🫢


✨ NAME ✨

SDL_ReadStorageFile β€” synchronously read a file from a storage container straight into a buffer you provide. no threads, no drama, no waiting around, we're doing this right now. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_storage.h>

bool SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *destination, Uint64 length);

like. look at it. one line. one call. iconic. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, and it's kind of the whole thing: the value of length must match the length of the file exactly. not kinda-sorta. not "close enough." exactly. 😭

and how do you find out what that number is? you call SDL_GetStorageFileSize() to get it, bestie. that's the move. πŸŽ€

lowkey important: this behavior may be relaxed in a future release. but that's a future-release problem, not a you-right-now problem. right now? exact length. periodt. πŸ’€

🌈 FUNCTION PARAMETERS 🌈

  • storage β€” a storage container to read from. this is the little home your file lives in, so to speak. 🏠
  • path β€” the relative path of the file to read. relative, bestie, not an absolute "i know where everything is on this machine" situation. 🧚
  • destination β€” a client-provided buffer to read the file into. client-provided means you bring the buffer. you're the main character here. 🌟
  • length β€” the length of the destination buffer. (and remember what we said up in DESCRIPTION? yeah. that one. πŸ™ˆ)

⭐ RETURN VALUE ⭐

returns true if the file was read, or false on failure. πŸ’–

and if you get false? don't panic, just call SDL_GetError() for more information β€” it will tell you what went wrong, like a friend who actually communicates. 🫢


πŸ’œ AVAILABILITY πŸ’œ

this function is available since SDL 3.2.0. so if you're on something older, sorry bestie, no file for you. πŸ’…


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, no cap. brought to you by the fine folks at Simple Directmedia Layer, running the SDL 3.4.18 era of things β€” thanks for reading, mwah, go read your files responsibly πŸ’–πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from