SDL_RWFromFP -- opens a file from a stdio file pointer.


#include "SDL.h"

SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose);


SDL_RWFromFP creates a new SDL_RWops structure from a file pointer, opened with stdio. If autoclose is nonzero, the file will be automatically closed when the RWops structure is closed.

Note: This is not available under Win32, since files opened in an application on that platform cannot be used by a dynamically linked library.

Note: This function is not present in SDL-1.2-svn4446

Return Value

Returns pointer to a new RWops structure, or NULL if it fails.


FILE *fp;
SDL_RWops *rw;

fp = fopen("myfile.dat", "rb");
rw = SDL_RWFromFP(fp, 1);

// Do things with rw...

SDL_RWclose(rw); // Automatically does an fclose(fp)

See Also

SDL_RWFromFile, SDL_RWFromMem

SDL_RWFromFP (last edited 2009-06-15 19:13:38 by 82-171-113-142)