Wiki Page Content

Differences between revisions 17 and 18
Revision 17 as of 2015-04-26 19:15:04
Size: 1558
Comment: Removed a redundant link and sorted related functions, see SGFunctions.
Revision 18 as of 2015-06-20 19:58:46
Size: 1562
Comment: Added link to [[SDL_RWops]].
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
Use this function to create an SDL_RWops structure from a standard I/O file pointer (stdio.h's `FILE*`). Use this function to create an [[SDL_RWops]] structure from a standard I/O file pointer (stdio.h's `FILE*`).

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.

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 */

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.

On some platforms, the first parameter is a void*, on others, it's a FILE*, depending on what system headers are available to SDL. It is always intended to be the FILE* type from the C runtime's stdio.h.


CategoryAPI, CategoryIO

None: SDL_RWFromFP (last edited 2015-06-20 19:58:46 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit