Fixed bug 3292 - SDL_rwops and 64-bit file I/O

Juha Niemim?

On AmigaOS 4 platform with Newlib 'C' library, there is a problem with failing fseeko64. This seemed to be caused by using fopen instead of fopen64.
This commit is contained in:
Sam Lantinga 2017-08-11 21:16:33 -07:00
parent 4c239e55f9
commit a48c9e6df8
5 changed files with 22 additions and 17 deletions

View file

@ -292,6 +292,23 @@ windows_file_close(SDL_RWops * context)
#ifdef HAVE_STDIO_H
#ifdef HAVE_FOPEN64
#define fopen fopen64
#endif
#ifdef HAVE_FSEEKO64
#define fseek_off_t off64_t
#define fseek fseeko64
#define ftell ftello64
#elif defined(HAVE_FSEEKO)
#define fseek_off_t off_t
#define fseek fseeko
#define ftell ftello
#elif defined(HAVE__FSEEKI64)
#define fseek_off_t __int64
#define fseek _fseeki64
#define ftell _ftelli64
#endif
/* Functions to read/write stdio file pointers */
static Sint64 SDLCALL
@ -312,23 +329,9 @@ stdio_size(SDL_RWops * context)
static Sint64 SDLCALL
stdio_seek(SDL_RWops * context, Sint64 offset, int whence)
{
#ifdef HAVE_FSEEKO64
if (fseeko64(context->hidden.stdio.fp, (off64_t)offset, whence) == 0) {
return ftello64(context->hidden.stdio.fp);
}
#elif defined(HAVE_FSEEKO)
if (fseeko(context->hidden.stdio.fp, (off_t)offset, whence) == 0) {
return ftello(context->hidden.stdio.fp);
}
#elif defined(HAVE__FSEEKI64)
if (_fseeki64(context->hidden.stdio.fp, offset, whence) == 0) {
return _ftelli64(context->hidden.stdio.fp);
}
#else
if (fseek(context->hidden.stdio.fp, offset, whence) == 0) {
if (fseek(context->hidden.stdio.fp, (fseek_off_t)offset, whence) == 0) {
return ftell(context->hidden.stdio.fp);
}
#endif
return SDL_Error(SDL_EFSEEK);
}