mirror of https://github.com/encounter/SDL.git
Fixed bug 4820 - SDL assumes RW_SEEK_SET == SEEK_SET
This commit is contained in:
parent
a747106c97
commit
97901b9f97
|
@ -361,13 +361,29 @@ stdio_size(SDL_RWops * context)
|
||||||
static Sint64 SDLCALL
|
static Sint64 SDLCALL
|
||||||
stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
|
stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
|
||||||
{
|
{
|
||||||
|
int stdiowhence;
|
||||||
|
|
||||||
|
switch (whence) {
|
||||||
|
case RW_SEEK_SET:
|
||||||
|
stdiowhence = SEEK_SET;
|
||||||
|
break;
|
||||||
|
case RW_SEEK_CUR:
|
||||||
|
stdiowhence = SEEK_CUR;
|
||||||
|
break;
|
||||||
|
case RW_SEEK_END:
|
||||||
|
stdiowhence = SEEK_END;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return SDL_SetError("Unknown value for 'whence'");
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(FSEEK_OFF_MIN) && defined(FSEEK_OFF_MAX)
|
#if defined(FSEEK_OFF_MIN) && defined(FSEEK_OFF_MAX)
|
||||||
if (offset < (Sint64)(FSEEK_OFF_MIN) || offset > (Sint64)(FSEEK_OFF_MAX)) {
|
if (offset < (Sint64)(FSEEK_OFF_MIN) || offset > (Sint64)(FSEEK_OFF_MAX)) {
|
||||||
return SDL_SetError("Seek offset out of range");
|
return SDL_SetError("Seek offset out of range");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fseek(context->hidden.stdio.fp, (fseek_off_t)offset, whence) == 0) {
|
if (fseek(context->hidden.stdio.fp, (fseek_off_t)offset, stdiowhence) == 0) {
|
||||||
Sint64 pos = ftell(context->hidden.stdio.fp);
|
Sint64 pos = ftell(context->hidden.stdio.fp);
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
return SDL_SetError("Couldn't get stream offset");
|
return SDL_SetError("Couldn't get stream offset");
|
||||||
|
|
Loading…
Reference in New Issue