Wiki Page Content

Differences between revisions 10 and 11
Revision 10 as of 2013-07-11 13:14:39
Size: 1485
Comment: Integrated some comments into the function parameters.
Revision 11 as of 2013-08-08 18:44:15
Size: 1101
Editor: RyanGordon
Comment: Rewritten
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%"style="color:#FF0000; ;text-align:center">DRAFT ||
Line 7: Line 5:
Use this function to perform a do-nothing seek to get the current offset in an SDL_RWops data stream. Use this function to determine the current read/write offset in an SDL_RWops data stream.
Line 20: Line 18:
*Returns the current offset in the stream.* Returns the current offset in the stream, or -1 if the information can not be determined.
Line 23: Line 21:
*
Line 26: Line 22:
#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);
  }

  SDL_RWseek(rw,0,RW_SEEK_END);
  fprintf(stderr,"Final position in test.bin: %d\n",SDL_RWtell(rw));
  SDL_RWclose(rw);
  return(0);
extern SDL_RWops *rw;
printf("Current position in test.bin: %lld\n", (long long) SDL_RWtell(rw));
if (SDL_RWseek(rw, 0, RW_SEEK_END) != -1) {
    printf("Final position in test.bin: %lld\n", (long long) SDL_RWtell(rw));
Line 44: Line 28:
*
Line 47: Line 30:
*<<BR>>This is not a built-in function. This is a macro that calls whatever seek function that happens to be pointed to in an SDL_RWops structure.<<BR>>* SDL_RWtell is actually a macro that calls the SDL_RWops's '''seek''' method, with an offset of 0 bytes from RW_SEEK_CUR, to simplify application development.
Line 50: Line 33:
 . [[SDL_RWclose]] (Macro) *
 . [[SDL_RWFromFile]] *

 . [[SDL_RWread]] (Macro) *
 . [[SDL_RWseek]](Macro) *
 . [[SDL_RWwrite]] (Macro) *
 . [[SDL_RWclose]]
 . [[SDL_RWread]]
 . [[SDL_RWseek]]
 . [[SDL_RWwrite]]
Line 56: Line 38:
{{{#!wiki comment
Should the current read and write functions (not macros) be listed? Should macros be identified as macros here?
}}}

SDL_RWtell

Use this function to determine the current read/write offset in an SDL_RWops data stream.

Syntax

Sint64 SDL_RWtell(struct SDL_RWops* context)

Function Parameters

context

a SDL_RWops data stream object from which to get the current offset

Return Value

Returns the current offset in the stream, or -1 if the information can not be determined.

Code Examples

extern SDL_RWops *rw;
printf("Current position in test.bin: %lld\n", (long long) SDL_RWtell(rw));
if (SDL_RWseek(rw, 0, RW_SEEK_END) != -1) {
    printf("Final position in test.bin: %lld\n", (long long) SDL_RWtell(rw));
}

Remarks

SDL_RWtell is actually a macro that calls the SDL_RWops's seek method, with an offset of 0 bytes from RW_SEEK_CUR, to simplify application development.


CategoryAPI, CategoryIO

None: SDL_RWtell (last edited 2015-06-20 19:57:52 by PhilippWiesemann)

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