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 π₯
SDL_GetStorageFileSize(3)β go here FIRST to get that exact length. seriously. πΈSDL_StorageReady(3)β vibe check your storage before you go reading from it. β¨SDL_WriteStorageFile(3)β the other direction, for when you're the one doing the writing. π¦
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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms