Skip to content

Commit 76773bd

Browse files
committed
Fix up SDL_RWops -> SDL_IOStream for SDL3 port.
1 parent a8de8cc commit 76773bd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dirksimple_sdl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ void DirkSimple_writelog(const char *str)
7575

7676
static long DirkSimple_rwops_read(DirkSimple_Io *io, void *buf, long buflen)
7777
{
78-
return (long) /* FIXME MIGRATION: double-check if you use the returned value of SDL_RWread() */
79-
SDL_ReadIO((SDL_IOStream *) io->userdata, buf, buflen);
78+
SDL_IOStream *stream = (SDL_IOStream *) io->userdata;
79+
const size_t br = SDL_ReadIO(stream, buf, buflen);
80+
if ((br == 0) && (SDL_GetIOStatus(stream) != SDL_IO_STATUS_EOF)) {
81+
return -1;
82+
}
83+
return (long) br;
8084
}
8185

8286
static long DirkSimple_rwops_streamlen(DirkSimple_Io *io)
8387
{
84-
SDL_IOStream *rwops = (SDL_IOStream *) io->userdata;
85-
const Sint64 origpos = SDL_TellIO(rwops);
86-
const long retval = (long) SDL_SeekIO(rwops, 0, SDL_IO_SEEK_END);
87-
SDL_SeekIO(rwops, origpos, SDL_IO_SEEK_SET);
88-
return retval;
88+
return (long) SDL_GetIOSize((SDL_IOStream *) io->userdata);
8989
}
9090

9191
static int DirkSimple_rwops_seek(DirkSimple_Io *io, long absolute_offset)

0 commit comments

Comments
 (0)