Wiki Page Content

Differences between revisions 6 and 7
Revision 6 as of 2013-06-15 16:19:22
Size: 1636
Comment: Changed signature to match SDL_main.h.
Revision 7 as of 2013-08-08 18:30:50
Size: 1138
Editor: RyanGordon
Comment: Rewritten
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
Use this function to close and free an allocated SDL_RWops structure ''-or-'' *call the close function in an SDL_RWops structure*. <<Color2(green,Should the wording here be changed to reflect the data stream concept as with other references to SDL_RWops?)>> Use this function to close and free an allocated SDL_RWops structure.
Line 16: Line 16:
||'''context'''||the ,,SDL_RWops structure,, ^data stream^ to close|| ||'''context'''||SDL_RWops structure to close||
Line 21: Line 21:
<<Color2(purple,If a write error occurs when flushing data it returns -1.)>>
Line 24: Line 22:
*
Line 26: Line 23:
#include <stdio.h>
#include "SDL_rwops.h"

int main(int argc, char *argv[])
{
  SDL_RWops *rw=SDL_RWFromFile("test.bin","r");
  if(rw==NULL)
  {
    fprintf(stderr,"Couldn't open test.bin\n");
    return(1);
  }
  fprintf(stderr,"Opened test.bin\n");
SDL_RWops *rw = SDL_RWFromFile("test.bin","r");
if(rw != NULL) {
  extern Uint8 buf[256];
  SDL_RWread(rw, buf, sizeof (buf));
Line 39: Line 28:
  fprintf(stderr,"Closed test.bin\n");
  return(0);
Line 43: Line 30:
*
Line 46: Line 32:
*<<BR>>This is not a built-in function. This is a macro that calls whatever close function happens to be pointed to by an SDL_RWops structure.<<BR>>* Note that if this fails to flush the stream to disk, this function reports an error, but the RWops is still invalid once this function returns.

SDL_RWclose is actually a macro that calls the SDL_RWops's '''close''' method appropriately, to simplify application development.
Line 49: Line 37:
 .[[SDL_RWFromFile]] *
 .[[SDL_RWread]] (Macro) *
 .[[SDL_RWseek]](Macro) *
 .[[SDL_RWwrite]] (Macro) *

<<Color2(green,Should the current read and write functions (not macros) be listed?)>>
 .[[SDL_RWread]]
 .[[SDL_RWseek]]
 .[[SDL_RWwrite]]

DRAFT

SDL_RWclose

Use this function to close and free an allocated SDL_RWops structure.

Syntax

int SDL_RWclose(struct SDL_RWops* context)

Function Parameters

context

SDL_RWops structure to close

Return Value

Returns 0 on success or a negative error code on failure; call SDL_GetError() for more information.

Code Examples

SDL_RWops *rw = SDL_RWFromFile("test.bin","r");
if(rw != NULL) {
  extern Uint8 buf[256];
  SDL_RWread(rw, buf, sizeof (buf));
  SDL_RWclose(rw);
}

Remarks

Note that if this fails to flush the stream to disk, this function reports an error, but the RWops is still invalid once this function returns.

SDL_RWclose is actually a macro that calls the SDL_RWops's close method appropriately, to simplify application development.


CategoryAPI, CategoryIO

None: SDL_RWclose (last edited 2015-06-20 19:55:24 by PhilippWiesemann)

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