SDL_AsyncIOFromFile(3)
π SDL_AsyncIOFromFile(3) π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_AsyncIOFromFile. it's giving "let's open a file but make it async-core." π¦
β¨ NAME β¨
SDL_AsyncIOFromFile β use this function to create a brand new SDL_AsyncIO object for reading from and/or writing to a named file. yes, and/or. it's versatile like that. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_asyncio.h>
SDL_AsyncIO * SDL_AsyncIOFromFile(const char *file, const char *mode);
π DESCRIPTION π
so the mode string? it understands these values, and you have to pick one of them, no freestyling:
"r"β opens a file for reading only. it must exist, bestie. no file, no vibe. π"w"β opens a file for writing only. it'll create the file if it's missing, or truncate it if it's already there. bye bye old content π"r+"β opens a file for update, both reading and writing. the file must exist. it's a two-for-one, we love to see it π«Ά"w+"β creates an empty file for both reading and writing. if a file with the same name already exists, its content is erased and the file gets treated as a new empty file. periodt. π₯
no"b"mode, because there's only"binary"style I/O around here β that's just the house style. and no"a"mode for appending either, because you specify the position when you start a task. you're the boss of that. π
also: this function supports Unicode filenames, but they must be encoded in UTF-8 format, regardless of the underlying operating system. no exceptions, no excuses. β¨
and like, lowkey important β this call is _not_ asynchronous. it opens the file before returning, operating on the assumption that opening a file is generally a fast operation. but the future reads and writes to the opened file will be async, however. slay. π
π§ FUNCTION PARAMETERS π§
fileβ a UTF-8 string representing the filename to open. πmodeβ an ASCII string representing the mode to be used for opening the file. pick from the list above, iykyk.
β RETURN VALUE β
returns a pointer to the SDL_AsyncIO structure that is created, or NULL on failure β and if it fails, call SDL_GetError() for more information. don't just sit there guessing, the error message is right there bestie π
π₯ THREAD SAFETY π₯
it is safe to call this function from any thread. go off, multithreaded queen π
π AVAILABILITY π
this function is available since SDL 3.2.0. vintage-ish but make it fresh.
π SEE ALSO π
and that's the whole page, no cap. brought to you by Simple Directmedia Layer, version SDL 3.4.18 β catch you in the next manpage, mwah πβ¨π
π¦ 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