Use this function to create a new SDL_RWops structure for reading from and/or writing to a named file.
const char *file, SDL_RWops* SDL_RWFromFile(const char *mode);
|file||a UTF-8 string representing the filename to open|
|mode||an ASCII string representing the mode to be used for opening the file.|
Returns a pointer to the SDL_RWops structure that is created, or NULL on failure; call SDL_GetError() for more information.
mode string is treated roughly the same as in a call to the C library's fopen(), even if SDL doesn't happen to use fopen() behind the scenes.
NOTE: In order to open a file as a binary file, a "b" character has to be included in the
mode string. This additional "b" character can either be appended at the end of the string (thus making the following compound modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+"). Additional characters may follow the sequence, although they should have no effect. For example, "t" is sometimes appended to make explicit the file is a text file.
This function supports Unicode filenames, but they must be encoded in UTF-8 format, regardless of the underlying operating system.
As a fallback, SDL_RWFromFile() will transparently open a matching filename in an Android app's
Closing the SDL_RWops will close the file handle SDL is holding internally.
This function is available since SDL 3.0.0.
"myimage.bmp", "rb"); SDL_RWops *file = SDL_RWFromFile(1); /* 1 to automatically close the RWops. */ SDL_Surface *image = SDL_LoadBMP_RW(file, /* Do something with image here. */