Revert "Fix return value of VFS seek function (#18561)" (#18583)

This reverts commit 85ae584b09d239e8ef05476ec9550a50720f984c.
This commit is contained in:
sonninnos 2026-01-04 20:33:01 +02:00 committed by GitHub
parent 233db048ee
commit f754e91a22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 37 deletions

View File

@ -89,7 +89,7 @@ int rfclose(RFILE* stream);
int64_t rftell(RFILE* stream);
/** @see https://en.cppreference.com/w/c/io/fseek */
int rfseek(RFILE* stream, int64_t offset, int origin);
int64_t rfseek(RFILE* stream, int64_t offset, int origin);
/** @see https://en.cppreference.com/w/c/io/fread */
int64_t rfread(void* buffer,

View File

@ -83,7 +83,7 @@ int64_t rftell(RFILE* stream)
return filestream_tell(stream);
}
int rfseek(RFILE* stream, int64_t offset, int origin)
int64_t rfseek(RFILE* stream, int64_t offset, int origin)
{
int seek_position = -1;
@ -103,7 +103,7 @@ int rfseek(RFILE* stream, int64_t offset, int origin)
break;
}
return filestream_seek(stream, offset, seek_position) == -1 ? -1 : 0;
return filestream_seek(stream, offset, seek_position);
}
int64_t rfread(void* buffer,

View File

@ -242,23 +242,11 @@ int64_t retro_vfs_file_seek_internal(
#endif
#ifdef ATLEAST_VC2005
/* VC2005 and up have a special 64-bit fseek */
if (_fseeki64(stream->fp, offset, whence) != 0)
return -1;
if ((val = _ftelli64(stream->fp)) < 0)
return -1;
return val;
return _fseeki64(stream->fp, offset, whence);
#elif defined(HAVE_64BIT_OFFSETS)
if (fseeko(stream->fp, (off_t)offset, whence) != 0)
return -1;
if ((val = ftello(stream->fp)) < 0)
return -1;
return val;
return fseeko(stream->fp, (off_t)offset, whence);
#else
if (fseek(stream->fp, (long)offset, whence) != 0)
return -1;
if ((val = ftell(stream->fp)) < 0)
return -1;
return val;
return fseek(stream->fp, (long)offset, whence);
#endif
}
#ifdef HAVE_MMAP
@ -730,17 +718,11 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
#endif
#ifdef ATLEAST_VC2005
/* VC2005 and up have a special 64-bit ftell */
if ((val = _ftelli64(stream->fp)) < 0)
return -1;
return val;
return _ftelli64(stream->fp);
#elif defined(HAVE_64BIT_OFFSETS)
if ((val = ftello(stream->fp)) < 0)
return -1;
return val;
return ftello(stream->fp);
#else
if ((val = ftell(stream->fp)) < 0)
return -1;
return val;
return ftell(stream->fp);
#endif
}
#ifdef HAVE_MMAP

View File

@ -21,7 +21,6 @@
*/
#include <vfs/vfs_implementation.h>
#include <vfs/vfs_implementation_cdrom.h>
#include <file/file_path.h>
#include <compat/fopen_utf8.h>
#include <string/stdstring.h>
@ -140,7 +139,7 @@ int64_t retro_vfs_file_seek_cdrom(
else
return -1;
return retro_vfs_file_tell_cdrom(stream);
return 0;
}
void retro_vfs_file_open_cdrom(

View File

@ -113,34 +113,30 @@ int64_t retro_vfs_file_truncate_impl(libretro_vfs_implementation_file* stream, i
int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file* stream)
{
int64_t val;
if (!stream)
return -1;
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
return _ftelli64(stream->fp);
if ((val = lseek(stream->fd, 0, SEEK_CUR)) < 0)
if (lseek(stream->fd, 0, SEEK_CUR) < 0)
return -1;
return val;
return 0;
}
int64_t retro_vfs_file_seek_internal(
libretro_vfs_implementation_file* stream,
int64_t offset, int whence)
{
int64_t val;
if (!stream)
return -1;
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
return _fseeki64(stream->fp, offset, whence);
if ((val = lseek(stream->fd, (off_t)offset, whence)) < 0)
if (lseek(stream->fd, (off_t)offset, whence) < 0)
return -1;
return val;
return 0;
}
int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file* stream,