From b0b588a56a7ff954a441650e1461a53bff0ba5cf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jun 2020 13:41:59 +0200 Subject: [PATCH] (VFS) Add fseeko/ftello support --- libretro-common/vfs/vfs_implementation.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index 4afb009e87..f8ff450ee4 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -177,6 +177,12 @@ #include #endif +#if (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0) >= 200112) || (defined(__POSIX_VISIBLE) && __POSIX_VISIBLE >= 200112) || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112) || __USE_LARGEFILE +#ifndef HAVE_64BIT_OFFSETS +#define HAVE_64BIT_OFFSETS +#endif +#endif + #define RFILE_HINT_UNBUFFERED (1 << 8) int64_t retro_vfs_file_seek_internal( @@ -195,8 +201,6 @@ int64_t retro_vfs_file_seek_internal( /* VC2005 and up have a special 64-bit fseek */ #ifdef ATLEAST_VC2005 return _fseeki64(stream->fp, offset, whence); -#elif defined(__CELLOS_LV2__) || defined(_MSC_VER) && _MSC_VER <= 1310 - return fseek(stream->fp, (long)offset, whence); #elif defined(ORBIS) { int ret = orbisLseek(stream->fd, offset, whence); @@ -204,8 +208,10 @@ int64_t retro_vfs_file_seek_internal( return -1; return 0; } -#else +#elif defined(HAVE_64BIT_OFFSETS) return fseeko(stream->fp, (off_t)offset, whence); +#else + return fseek(stream->fp, (long)offset, whence); #endif } #ifdef HAVE_MMAP @@ -604,6 +610,8 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream) /* VC2005 and up have a special 64-bit ftell */ #ifdef ATLEAST_VC2005 return _ftelli64(stream->fp); +#elif defined(HAVE_64BIT_OFFSETS) + return ftello(stream->fp); #else return ftell(stream->fp); #endif