SDL Wiki
(This is the documentation for SDL3, which is under heavy development and the API is changing! SDL2 is the current stable version!)

SDL_RWFromFP

Use this function to create an SDL_RWops structure from a standard I/O file pointer (stdio.h's FILE *).

Syntax

SDL_RWops* SDL_RWFromFP(void *fp, SDL_bool autoclose);

Function Parameters

fp

the FILE * that feeds the SDL_RWops stream

autoclose

SDL_TRUE to close the FILE* when closing the SDL_RWops, SDL_FALSE to leave the FILE* open when the RWops is closed

Return Value

Returns a pointer to the SDL_RWops structure that is created, or NULL on failure; call SDL_GetError() for more information.

Remarks

This function is not available on Windows, since files opened in an application on that platform cannot be used by a dynamically linked library.

Version

This function is available since SDL 3.0.0.

Code Examples

FILE *fp = fopen("myfile.dat", "rb");
SDL_RWops *rw = SDL_RWFromFP(fp, SDL_TRUE);
/* Do things with rw... */
SDL_RWclose(rw); /* Automatically does an fclose(fp) in this case */
SDL_RWclose
SDL_RWFromConstMem
SDL_RWFromFile
SDL_RWFromMem
SDL_RWread
SDL_RWseek
SDL_RWtell
SDL_RWwrite

CategoryAPI, CategoryIO


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.