|
Size: 1401
Comment: update content for consistency - non-zero
|
Size: 1539
Comment: Rewritten
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 6: | Line 6: |
| Use this function to create an SDL_RWops structure from a standard I/O file pointer. | Use this function to create an SDL_RWops structure from a standard I/O file pointer (stdio.h's `FILE*`). |
| Line 12: | Line 12: |
| #ifdef HAVE_STDIO_H SDL_RWops* SDL_RWFromFP(FILE* fp, SDL_bool autoclose) #else |
|
| Line 21: | Line 17: |
| ||'''fp'''||,,a pointer to ,,^the file to open (in the new structure ???)^|| ||'''autoclose'''||^non-zero to autoclose or 0 to leave the file open when the structure is closed^ ???|| |
||'''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|| |
| Line 25: | Line 21: |
| *<<BR>>Returns a pointer to a new RWops structure, or NULL if it fails. <<BR>>* | Returns a pointer to the [[SDL_RWops]] structure that is created, or NULL on failure; call [[SDL_GetError]]() for more information. |
| Line 29: | Line 25: |
| FILE *fp; SDL_RWops *rw; fp = fopen("myfile.dat", "rb"); rw = SDL_RWFromFP(fp, 1); |
FILE *fp = fopen("myfile.dat", "rb"); SDL_RWops *rw = SDL_RWFromFP(fp, SDL_TRUE); |
| Line 36: | Line 28: |
SDL_RWclose(rw); // Automatically does an fclose(fp) |
SDL_RWclose(rw); /* Automatically does an fclose(fp) in this case */ |
| Line 41: | Line 32: |
| ''You can add useful comments here'' | This function is not available on Windows, since files opened in an application on that platform cannot be used by a dynamically linked library. |
| Line 43: | Line 34: |
| *<<BR>>This is not available under Win32, since files opened in an application on that platform cannot be used by a dynamically linked library.<<BR>>* | 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. |
| Line 46: | Line 37: |
| .[[SDL_RWclose]] (Macro) ??? .[[SDL_RWFromConstMem]] ??? .[[SDL_RWFromFile]] * .[[SDL_RWFromMem]] * |
.[[SDL_RWclose]] .[[SDL_RWFromConstMem]] .[[SDL_RWFromFile]] .[[SDL_RWFromMem]] |
DRAFT |
SDL_RWFromFP
Use this function to create an SDL_RWops structure from a standard I/O file pointer (stdio.h's FILE*).
Contents
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.
