rwops: Rename everything from SDL_RWxxx to SDL_XxxRW.

main
Ryan C. Gordon 2024-03-12 16:01:59 -04:00
parent 655ceb3b31
commit 7d4d8ccde0
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
18 changed files with 271 additions and 226 deletions

View File

@ -3048,3 +3048,33 @@ typedef SDL_version, SDL_Version;
- SDL_JoystickGetBall
+ SDL_GetJoystickBall
(...)
@@
@@
- SDL_RWclose
+ SDL_CloseRW
(...)
@@
@@
- SDL_RWread
+ SDL_ReadRW
(...)
@@
@@
- SDL_RWwrite
+ SDL_WriteRW
(...)
@@
@@
- SDL_RWtell
+ SDL_TellRW
(...)
@@
@@
- SDL_RWsize
+ SDL_SizeRW
(...)
@@
@@
- SDL_RWseek
+ SDL_SeekRW
(...)

View File

@ -1156,11 +1156,11 @@ The following symbols have been renamed:
* RW_SEEK_END => SDL_RW_SEEK_END
* RW_SEEK_SET => SDL_RW_SEEK_SET
SDL_RWops is now an opaque structure. The existing APIs to create a RWops (SDL_RWFromFile, etc) still function as expected, but to make a custom RWops with app-provided function pointers, call SDL_OpenRW and provide the function pointers through there. To call into a RWops's functionality, use the standard APIs (SDL_RWread, etc) instead of calling into function pointers directly.
SDL_RWops is now an opaque structure. The existing APIs to create a RWops (SDL_RWFromFile, etc) still function as expected, but to make a custom RWops with app-provided function pointers, call SDL_OpenRW and provide the function pointers through there. To call into a RWops's functionality, use the standard APIs (SDL_ReadRW, etc) instead of calling into function pointers directly.
The RWops function pointers are now in a separate structure called SDL_RWopsInteface, which is provided to SDL_OpenRW. All the functions now take a `void *` userdata argument for their first parameter instead of an SDL_RWops, since that's now an opaque structure.
SDL_RWread and SDL_RWwrite (and SDL_RWopsInterface::read, SDL_RWopsInterface::write) have a different function signature in SDL3.
SDL_RWread and SDL_RWwrite (and the read and write function pointers) have a different function signature in SDL3 in addition to being renamed.
Previously they looked more like stdio:
@ -1172,8 +1172,8 @@ size_t SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size, size_t maxn
But now they look more like POSIX:
```c
size_t SDL_RWread(void *userdata, void *ptr, size_t size);
size_t SDL_RWwrite(void *userdata, const void *ptr, size_t size);
size_t SDL_ReadRW(void *userdata, void *ptr, size_t size);
size_t SDL_WriteRW(void *userdata, const void *ptr, size_t size);
```
Code that used to look like this:
@ -1188,7 +1188,7 @@ should be changed to:
size_t custom_read(void *ptr, size_t size, size_t nitems, SDL_RWops *stream)
{
if (size > 0 && nitems > 0) {
return SDL_RWread(stream, ptr, size * nitems) / size;
return SDL_ReadRW(stream, ptr, size * nitems) / size;
}
return 0;
}
@ -1200,7 +1200,7 @@ SDL_RWopsInterface::close implementations should clean up their own userdata, bu
SDL_RWFromFP has been removed from the API, due to issues when the SDL library uses a different C runtime from the application.
SDL_AllocRW(), SDL_FreeRW(), SDL_RWclose() and direct access to the `->close` function pointer have been removed from the API, so there's only one path to manage RWops lifetimes now: SDL_OpenRW() and SDL_CloseRW().
SDL_AllocRW(), SDL_FreeRW(), SDL_CloseRW() and direct access to the `->close` function pointer have been removed from the API, so there's only one path to manage RWops lifetimes now: SDL_OpenRW() and SDL_CloseRW().
You can implement this in your own code easily:
@ -1286,7 +1286,7 @@ SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
}
SDL_zero(iface);
/* There's no stdio_size because SDL_RWsize emulates it the same way we'd do it for stdio anyhow. */
/* There's no stdio_size because SDL_SizeRW emulates it the same way we'd do it for stdio anyhow. */
iface.seek = stdio_seek;
iface.read = stdio_read;
iface.write = stdio_write;
@ -1306,6 +1306,12 @@ SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
The functions SDL_ReadU8(), SDL_ReadU16LE(), SDL_ReadU16BE(), SDL_ReadU32LE(), SDL_ReadU32BE(), SDL_ReadU64LE(), and SDL_ReadU64BE() now return SDL_TRUE if the read succeeded and SDL_FALSE if it didn't, and store the data in a pointer passed in as a parameter.
The following functions have been renamed:
* SDL_RWclose() => SDL_CloseRW()
* SDL_RWread() => SDL_ReadRW()
* SDL_RWseek() => SDL_SeekRW()
* SDL_RWsize() => SDL_SizeRW()
* SDL_RWtell() => SDL_TellRW()
* SDL_RWwrite() => SDL_WriteRW()
* SDL_ReadBE16() => SDL_ReadU16BE()
* SDL_ReadBE32() => SDL_ReadU32BE()
* SDL_ReadBE64() => SDL_ReadU64BE()

View File

@ -452,6 +452,12 @@
#define RW_SEEK_CUR SDL_RW_SEEK_CUR
#define RW_SEEK_END SDL_RW_SEEK_END
#define RW_SEEK_SET SDL_RW_SEEK_SET
#define SDL_RWclose SDL_CloseRW
#define SDL_RWread SDL_ReadRW
#define SDL_RWseek SDL_SeekRW
#define SDL_RWsize SDL_SizeRW
#define SDL_RWtell SDL_TellRW
#define SDL_RWwrite SDL_WriteRW
#define SDL_ReadBE16 SDL_ReadU16BE
#define SDL_ReadBE32 SDL_ReadU32BE
#define SDL_ReadBE64 SDL_ReadU64BE
@ -936,6 +942,12 @@
#define RW_SEEK_CUR RW_SEEK_CUR_renamed_SDL_RW_SEEK_CUR
#define RW_SEEK_END RW_SEEK_END_renamed_SDL_RW_SEEK_END
#define RW_SEEK_SET RW_SEEK_SET_renamed_SDL_RW_SEEK_SET
#define SDL_RWclose SDL_RWclose_renamed_SDL_CloseRW
#define SDL_RWread SDL_RWread_renamed_SDL_ReadRW
#define SDL_RWseek SDL_RWseek_renamed_SDL_SeekRW
#define SDL_RWsize SDL_RWsize_renamed_SDL_SizeRW
#define SDL_RWtell SDL_RWtell_renamed_SDL_TellRW
#define SDL_RWwrite SDL_RWwrite_renamed_SDL_WriteRW
#define SDL_ReadBE16 SDL_ReadBE16_renamed_SDL_ReadU16BE
#define SDL_ReadBE32 SDL_ReadBE32_renamed_SDL_ReadU32BE
#define SDL_ReadBE64 SDL_ReadBE64_renamed_SDL_ReadU64BE

View File

@ -160,10 +160,10 @@ typedef struct SDL_RWops SDL_RWops;
*
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWtell
* \sa SDL_RWwrite
* \sa SDL_ReadRW
* \sa SDL_SeekRW
* \sa SDL_TellRW
* \sa SDL_WriteRW
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode);
@ -191,10 +191,10 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWtell
* \sa SDL_RWwrite
* \sa SDL_ReadRW
* \sa SDL_SeekRW
* \sa SDL_TellRW
* \sa SDL_WriteRW
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, size_t size);
@ -224,9 +224,9 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, size_t size);
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWtell
* \sa SDL_ReadRW
* \sa SDL_SeekRW
* \sa SDL_TellRW
*/
extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, size_t size);
@ -272,9 +272,9 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_OpenRW(const SDL_RWopsInterface *iface, v
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWwrite
* \sa SDL_ReadRW
* \sa SDL_SeekRW
* \sa SDL_WriteRW
*/
extern DECLSPEC int SDLCALL SDL_CloseRW(SDL_RWops *context);
@ -306,7 +306,7 @@ extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRWProperties(SDL_RWops *context)
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
extern DECLSPEC Sint64 SDLCALL SDL_SizeRW(SDL_RWops *context);
/**
* Seek within an SDL_RWops data stream.
@ -321,9 +321,6 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
*
* If this stream can not seek, it will return -1.
*
* SDL_RWseek() is actually a wrapper function that calls the SDL_RWops's
* `seek` method appropriately, to simplify application development.
*
* \param context a pointer to an SDL_RWops structure
* \param offset an offset in bytes, relative to **whence** location; can be
* negative
@ -337,16 +334,16 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWtell
* \sa SDL_RWwrite
* \sa SDL_ReadRW
* \sa SDL_TellRW
* \sa SDL_WriteRW
*/
extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence);
extern DECLSPEC Sint64 SDLCALL SDL_SeekRW(SDL_RWops *context, Sint64 offset, int whence);
/**
* Determine the current read/write offset in an SDL_RWops data stream.
*
* SDL_RWtell is actually a wrapper function that calls the SDL_RWops's `seek`
* SDL_TellRW is actually a wrapper function that calls the SDL_RWops's `seek`
* method, with an offset of 0 bytes from `SDL_RW_SEEK_CUR`, to simplify
* application development.
*
@ -360,11 +357,11 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, Sint64 offset, int
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWwrite
* \sa SDL_ReadRW
* \sa SDL_SeekRW
* \sa SDL_WriteRW
*/
extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
extern DECLSPEC Sint64 SDLCALL SDL_TellRW(SDL_RWops *context);
/**
* Read from a data source.
@ -377,7 +374,7 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
* that this is not an error or end-of-file, and the caller can try again
* later.
*
* SDL_RWread() is actually a function wrapper that calls the SDL_RWops's
* SDL_ReadRW() is actually a function wrapper that calls the SDL_RWops's
* `read` method appropriately, to simplify application development.
*
* \param context a pointer to an SDL_RWops structure
@ -390,10 +387,10 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWseek
* \sa SDL_RWwrite
* \sa SDL_SeekRW
* \sa SDL_WriteRW
*/
extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, void *ptr, size_t size);
extern DECLSPEC size_t SDLCALL SDL_ReadRW(SDL_RWops *context, void *ptr, size_t size);
/**
* Write to an SDL_RWops data stream.
@ -409,7 +406,7 @@ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, void *ptr, size_t
* written because it would require blocking, this function returns -2 to
* distinguish that this is not an error and the caller can try again later.
*
* SDL_RWwrite is actually a function wrapper that calls the SDL_RWops's
* SDL_WriteRW is actually a function wrapper that calls the SDL_RWops's
* `write` method appropriately, to simplify application development.
*
* It is an error to specify a negative `size`, but this parameter is signed
@ -428,10 +425,10 @@ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, void *ptr, size_t
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWprint
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_ReadRW
* \sa SDL_SeekRW
*/
extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size);
extern DECLSPEC size_t SDLCALL SDL_WriteRW(SDL_RWops *context, const void *ptr, size_t size);
/**
* Print to an SDL_RWops data stream.
@ -450,9 +447,9 @@ extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, const void *ptr,
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWwrite
* \sa SDL_ReadRW
* \sa SDL_SeekRW
* \sa SDL_WriteRW
*/
extern DECLSPEC size_t SDLCALL SDL_RWprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
@ -472,9 +469,9 @@ extern DECLSPEC size_t SDLCALL SDL_RWprintf(SDL_RWops *context, SDL_PRINTF_FORMA
* \sa SDL_RWFromConstMem
* \sa SDL_RWFromFile
* \sa SDL_RWFromMem
* \sa SDL_RWread
* \sa SDL_RWseek
* \sa SDL_RWwrite
* \sa SDL_ReadRW
* \sa SDL_SeekRW
* \sa SDL_WriteRW
*/
extern DECLSPEC size_t SDLCALL SDL_RWvprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);

View File

@ -1520,10 +1520,10 @@ static int WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
nextposition++;
}
if (SDL_RWseek(src, nextposition, SDL_RW_SEEK_SET) != nextposition) {
if (SDL_SeekRW(src, nextposition, SDL_RW_SEEK_SET) != nextposition) {
/* Not sure how we ended up here. Just abort. */
return -2;
} else if (SDL_RWread(src, chunkheader, sizeof(Uint32) * 2) != (sizeof(Uint32) * 2)) {
} else if (SDL_ReadRW(src, chunkheader, sizeof(Uint32) * 2) != (sizeof(Uint32) * 2)) {
return -1;
}
@ -1548,12 +1548,12 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len
return -1;
}
if (SDL_RWseek(src, chunk->position, SDL_RW_SEEK_SET) != chunk->position) {
if (SDL_SeekRW(src, chunk->position, SDL_RW_SEEK_SET) != chunk->position) {
/* Not sure how we ended up here. Just abort. */
return -2;
}
chunk->size = SDL_RWread(src, chunk->data, length);
chunk->size = SDL_ReadRW(src, chunk->data, length);
if (chunk->size != length) {
/* Expected to be handled by the caller. */
}
@ -1655,7 +1655,7 @@ static int WaveReadFormat(WaveFile *file)
if (!SDL_ReadU16LE(fmtsrc, &format->validsamplebits) ||
!SDL_ReadU32LE(fmtsrc, &format->channelmask) ||
SDL_RWread(fmtsrc, format->subformat, 16) != 16) {
SDL_ReadRW(fmtsrc, format->subformat, 16) != 16) {
}
format->samplesperblock = format->validsamplebits;
format->encoding = WaveGetFormatGUIDEncoding(format);
@ -1795,7 +1795,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
}
}
RIFFstart = SDL_RWtell(src);
RIFFstart = SDL_TellRW(src);
if (RIFFstart < 0) {
return SDL_SetError("Could not seek in file");
}
@ -1897,7 +1897,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
file->fact.status = -1;
} else {
/* Let's use src directly, it's just too convenient. */
Sint64 position = SDL_RWseek(src, chunk->position, SDL_RW_SEEK_SET);
Sint64 position = SDL_SeekRW(src, chunk->position, SDL_RW_SEEK_SET);
if (position == chunk->position && SDL_ReadU32LE(src, &file->fact.samplelength)) {
file->fact.status = 1;
} else {
@ -1940,7 +1940,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
if (chunk->fourcc != DATA && chunk->length > 0) {
Uint8 tmp;
Uint64 position = (Uint64)chunk->position + chunk->length - 1;
if (position > SDL_MAX_SINT64 || SDL_RWseek(src, (Sint64)position, SDL_RW_SEEK_SET) != (Sint64)position) {
if (position > SDL_MAX_SINT64 || SDL_SeekRW(src, (Sint64)position, SDL_RW_SEEK_SET) != (Sint64)position) {
return SDL_SetError("Could not seek to WAVE chunk data");
} else if (!SDL_ReadU8(src, &tmp)) {
return SDL_SetError("RIFF size truncates chunk");
@ -2111,7 +2111,7 @@ int SDL_LoadWAV_RW(SDL_RWops *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uint8
/* Cleanup */
if (!freesrc) {
SDL_RWseek(src, file.chunk.position, SDL_RW_SEEK_SET);
SDL_SeekRW(src, file.chunk.position, SDL_RW_SEEK_SET);
}
WaveFreeChunkData(&file.chunk);
SDL_free(file.decoderdata);

View File

@ -43,7 +43,7 @@ static int DISKAUDIO_WaitDevice(SDL_AudioDevice *device)
static int DISKAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
{
const int written = (int)SDL_RWwrite(device->hidden->io, buffer, (size_t)buffer_size);
const int written = (int)SDL_WriteRW(device->hidden->io, buffer, (size_t)buffer_size);
if (written != buffer_size) { // If we couldn't write, assume fatal error for now
return -1;
}
@ -64,7 +64,7 @@ static int DISKAUDIO_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, in
const int origbuflen = buflen;
if (h->io) {
const int br = (int)SDL_RWread(h->io, buffer, (size_t)buflen);
const int br = (int)SDL_ReadRW(h->io, buffer, (size_t)buflen);
buflen -= br;
buffer = ((Uint8 *)buffer) + br;
if (buflen > 0) { // EOF (or error, but whatever).

View File

@ -467,11 +467,11 @@ SDL3_0.0.0 {
SDL_RWFromConstMem;
SDL_RWFromFile;
SDL_RWFromMem;
SDL_RWread;
SDL_RWseek;
SDL_RWsize;
SDL_RWtell;
SDL_RWwrite;
SDL_ReadRW;
SDL_SeekRW;
SDL_SizeRW;
SDL_TellRW;
SDL_WriteRW;
SDL_RaiseWindow;
SDL_ReadU16BE;
SDL_ReadU32BE;

View File

@ -491,11 +491,11 @@
#define SDL_RWFromConstMem SDL_RWFromConstMem_REAL
#define SDL_RWFromFile SDL_RWFromFile_REAL
#define SDL_RWFromMem SDL_RWFromMem_REAL
#define SDL_RWread SDL_RWread_REAL
#define SDL_RWseek SDL_RWseek_REAL
#define SDL_RWsize SDL_RWsize_REAL
#define SDL_RWtell SDL_RWtell_REAL
#define SDL_RWwrite SDL_RWwrite_REAL
#define SDL_ReadRW SDL_ReadRW_REAL
#define SDL_SeekRW SDL_SeekRW_REAL
#define SDL_SizeRW SDL_SizeRW_REAL
#define SDL_TellRW SDL_TellRW_REAL
#define SDL_WriteRW SDL_WriteRW_REAL
#define SDL_RaiseWindow SDL_RaiseWindow_REAL
#define SDL_ReadU16BE SDL_ReadU16BE_REAL
#define SDL_ReadU32BE SDL_ReadU32BE_REAL

View File

@ -536,11 +536,11 @@ SDL_DYNAPI_PROC(void,SDL_QuitSubSystem,(Uint32 a),(a),)
SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromConstMem,(const void *a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFile,(const char *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromMem,(void *a, size_t b),(a,b),return)
SDL_DYNAPI_PROC(size_t,SDL_RWread,(SDL_RWops *a, void *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(Sint64,SDL_RWseek,(SDL_RWops *a, Sint64 b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(Sint64,SDL_RWsize,(SDL_RWops *a),(a),return)
SDL_DYNAPI_PROC(Sint64,SDL_RWtell,(SDL_RWops *a),(a),return)
SDL_DYNAPI_PROC(size_t,SDL_RWwrite,(SDL_RWops *a, const void *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(size_t,SDL_ReadRW,(SDL_RWops *a, void *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(Sint64,SDL_SeekRW,(SDL_RWops *a, Sint64 b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(Sint64,SDL_SizeRW,(SDL_RWops *a),(a),return)
SDL_DYNAPI_PROC(Sint64,SDL_TellRW,(SDL_RWops *a),(a),return)
SDL_DYNAPI_PROC(size_t,SDL_WriteRW,(SDL_RWops *a, const void *b, size_t c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RaiseWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU16BE,(SDL_RWops *a, Uint16 *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU32BE,(SDL_RWops *a, Uint32 *b),(a,b),return)

View File

@ -415,7 +415,7 @@ static SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
SDL_RWopsInterface iface;
SDL_zero(iface);
// There's no stdio_size because SDL_RWsize emulates it the same way we'd do it for stdio anyhow.
// There's no stdio_size because SDL_SizeRW emulates it the same way we'd do it for stdio anyhow.
iface.seek = stdio_seek;
iface.read = stdio_read;
iface.write = stdio_write;
@ -748,7 +748,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
goto done;
}
size = SDL_RWsize(src);
size = SDL_SizeRW(src);
if (size < 0) {
size = FILE_CHUNK_SIZE;
loading_chunks = SDL_TRUE;
@ -780,7 +780,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
}
}
size_read = SDL_RWread(src, data + size_total, (size_t)(size - size_total));
size_read = SDL_ReadRW(src, data + size_total, (size_t)(size - size_total));
if (size_read > 0) {
size_total += size_read;
continue;
@ -820,7 +820,7 @@ SDL_PropertiesID SDL_GetRWProperties(SDL_RWops *context)
return context->props;
}
Sint64 SDL_RWsize(SDL_RWops *context)
Sint64 SDL_SizeRW(SDL_RWops *context)
{
if (!context) {
return SDL_InvalidParamError("context");
@ -828,19 +828,19 @@ Sint64 SDL_RWsize(SDL_RWops *context)
if (!context->iface.size) {
Sint64 pos, size;
pos = SDL_RWseek(context, 0, SDL_RW_SEEK_CUR);
pos = SDL_SeekRW(context, 0, SDL_RW_SEEK_CUR);
if (pos < 0) {
return -1;
}
size = SDL_RWseek(context, 0, SDL_RW_SEEK_END);
size = SDL_SeekRW(context, 0, SDL_RW_SEEK_END);
SDL_RWseek(context, pos, SDL_RW_SEEK_SET);
SDL_SeekRW(context, pos, SDL_RW_SEEK_SET);
return size;
}
return context->iface.size(context->userdata);
}
Sint64 SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence)
Sint64 SDL_SeekRW(SDL_RWops *context, Sint64 offset, int whence)
{
if (!context) {
return SDL_InvalidParamError("context");
@ -850,12 +850,12 @@ Sint64 SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence)
return context->iface.seek(context->userdata, offset, whence);
}
Sint64 SDL_RWtell(SDL_RWops *context)
Sint64 SDL_TellRW(SDL_RWops *context)
{
return SDL_RWseek(context, 0, SDL_RW_SEEK_CUR);
return SDL_SeekRW(context, 0, SDL_RW_SEEK_CUR);
}
size_t SDL_RWread(SDL_RWops *context, void *ptr, size_t size)
size_t SDL_ReadRW(SDL_RWops *context, void *ptr, size_t size)
{
size_t bytes;
@ -886,7 +886,7 @@ size_t SDL_RWread(SDL_RWops *context, void *ptr, size_t size)
return bytes;
}
size_t SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size)
size_t SDL_WriteRW(SDL_RWops *context, const void *ptr, size_t size)
{
size_t bytes;
@ -927,7 +927,7 @@ size_t SDL_RWprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fmt
return 0;
}
bytes = SDL_RWwrite(context, string, (size_t)size);
bytes = SDL_WriteRW(context, string, (size_t)size);
SDL_free(string);
return bytes;
}
@ -943,7 +943,7 @@ size_t SDL_RWvprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fm
return 0;
}
bytes = SDL_RWwrite(context, string, (size_t)size);
bytes = SDL_WriteRW(context, string, (size_t)size);
SDL_free(string);
return bytes;
}
@ -955,7 +955,7 @@ SDL_bool SDL_ReadU8(SDL_RWops *src, Uint8 *value)
Uint8 data = 0;
SDL_bool result = SDL_FALSE;
if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
result = SDL_TRUE;
}
if (value) {
@ -969,7 +969,7 @@ SDL_bool SDL_ReadU16LE(SDL_RWops *src, Uint16 *value)
Uint16 data = 0;
SDL_bool result = SDL_FALSE;
if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
result = SDL_TRUE;
}
if (value) {
@ -988,7 +988,7 @@ SDL_bool SDL_ReadU16BE(SDL_RWops *src, Uint16 *value)
Uint16 data = 0;
SDL_bool result = SDL_FALSE;
if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
result = SDL_TRUE;
}
if (value) {
@ -1007,7 +1007,7 @@ SDL_bool SDL_ReadU32LE(SDL_RWops *src, Uint32 *value)
Uint32 data = 0;
SDL_bool result = SDL_FALSE;
if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
result = SDL_TRUE;
}
if (value) {
@ -1026,7 +1026,7 @@ SDL_bool SDL_ReadU32BE(SDL_RWops *src, Uint32 *value)
Uint32 data = 0;
SDL_bool result = SDL_FALSE;
if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
result = SDL_TRUE;
}
if (value) {
@ -1045,7 +1045,7 @@ SDL_bool SDL_ReadU64LE(SDL_RWops *src, Uint64 *value)
Uint64 data = 0;
SDL_bool result = SDL_FALSE;
if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
result = SDL_TRUE;
}
if (value) {
@ -1064,7 +1064,7 @@ SDL_bool SDL_ReadU64BE(SDL_RWops *src, Uint64 *value)
Uint64 data = 0;
SDL_bool result = SDL_FALSE;
if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
result = SDL_TRUE;
}
if (value) {
@ -1080,13 +1080,13 @@ SDL_bool SDL_ReadS64BE(SDL_RWops *src, Sint64 *value)
SDL_bool SDL_WriteU8(SDL_RWops *dst, Uint8 value)
{
return (SDL_RWwrite(dst, &value, sizeof(value)) == sizeof(value));
return (SDL_WriteRW(dst, &value, sizeof(value)) == sizeof(value));
}
SDL_bool SDL_WriteU16LE(SDL_RWops *dst, Uint16 value)
{
const Uint16 swapped = SDL_SwapLE16(value);
return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
}
SDL_bool SDL_WriteS16LE(SDL_RWops *dst, Sint16 value)
@ -1097,7 +1097,7 @@ SDL_bool SDL_WriteS16LE(SDL_RWops *dst, Sint16 value)
SDL_bool SDL_WriteU16BE(SDL_RWops *dst, Uint16 value)
{
const Uint16 swapped = SDL_SwapBE16(value);
return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
}
SDL_bool SDL_WriteS16BE(SDL_RWops *dst, Sint16 value)
@ -1108,7 +1108,7 @@ SDL_bool SDL_WriteS16BE(SDL_RWops *dst, Sint16 value)
SDL_bool SDL_WriteU32LE(SDL_RWops *dst, Uint32 value)
{
const Uint32 swapped = SDL_SwapLE32(value);
return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
}
SDL_bool SDL_WriteS32LE(SDL_RWops *dst, Sint32 value)
@ -1119,7 +1119,7 @@ SDL_bool SDL_WriteS32LE(SDL_RWops *dst, Sint32 value)
SDL_bool SDL_WriteU32BE(SDL_RWops *dst, Uint32 value)
{
const Uint32 swapped = SDL_SwapBE32(value);
return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
}
SDL_bool SDL_WriteS32BE(SDL_RWops *dst, Sint32 value)
@ -1130,7 +1130,7 @@ SDL_bool SDL_WriteS32BE(SDL_RWops *dst, Sint32 value)
SDL_bool SDL_WriteU64LE(SDL_RWops *dst, Uint64 value)
{
const Uint64 swapped = SDL_SwapLE64(value);
return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
}
SDL_bool SDL_WriteS64LE(SDL_RWops *dst, Sint64 value)
@ -1141,7 +1141,7 @@ SDL_bool SDL_WriteS64LE(SDL_RWops *dst, Sint64 value)
SDL_bool SDL_WriteU64BE(SDL_RWops *dst, Uint64 value)
{
const Uint64 swapped = SDL_SwapBE64(value);
return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
}
SDL_bool SDL_WriteS64BE(SDL_RWops *dst, Sint64 value)

View File

@ -1904,10 +1904,10 @@ static const void *SDLTest_ScreenShotClipboardProvider(void *context, const char
file = SDL_RWFromFile(SCREENSHOT_FILE, "r");
if (file) {
size_t length = (size_t)SDL_RWsize(file);
size_t length = (size_t)SDL_SizeRW(file);
void *image = SDL_malloc(length);
if (image) {
if (SDL_RWread(file, image, length) != length) {
if (SDL_ReadRW(file, image, length) != length) {
SDL_Log("Couldn't read %s: %s\n", SCREENSHOT_FILE, SDL_GetError());
SDL_free(image);
image = NULL;
@ -1983,7 +1983,7 @@ static void SDLTest_PasteScreenShot(void)
file = SDL_RWFromFile(filename, "w");
if (file) {
SDL_Log("Writing clipboard image to %s", filename);
SDL_RWwrite(file, data, size);
SDL_WriteRW(file, data, size);
SDL_CloseRW(file);
}
SDL_free(data);

View File

@ -239,12 +239,12 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
}
/* Read in the BMP file header */
fp_offset = SDL_RWtell(src);
fp_offset = SDL_TellRW(src);
if (fp_offset < 0) {
goto done;
}
SDL_ClearError();
if (SDL_RWread(src, magic, 2) != 2) {
if (SDL_ReadRW(src, magic, 2) != 2) {
goto done;
}
if (SDL_strncmp(magic, "BM", 2) != 0) {
@ -340,9 +340,9 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
}
/* skip any header bytes we didn't handle... */
headerSize = (Uint32)(SDL_RWtell(src) - (fp_offset + 14));
headerSize = (Uint32)(SDL_TellRW(src) - (fp_offset + 14));
if (biSize > headerSize) {
if (SDL_RWseek(src, (biSize - headerSize), SDL_RW_SEEK_CUR) < 0) {
if (SDL_SeekRW(src, (biSize - headerSize), SDL_RW_SEEK_CUR) < 0) {
goto done;
}
}
@ -441,7 +441,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
/* Load the palette, if any */
palette = (surface->format)->palette;
if (palette) {
if (SDL_RWseek(src, fp_offset + 14 + biSize, SDL_RW_SEEK_SET) < 0) {
if (SDL_SeekRW(src, fp_offset + 14 + biSize, SDL_RW_SEEK_SET) < 0) {
SDL_Error(SDL_EFSEEK);
goto done;
}
@ -492,7 +492,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
}
/* Read the surface pixels. Note that the bmp image is upside down */
if (SDL_RWseek(src, fp_offset + bfOffBits, SDL_RW_SEEK_SET) < 0) {
if (SDL_SeekRW(src, fp_offset + bfOffBits, SDL_RW_SEEK_SET) < 0) {
SDL_Error(SDL_EFSEEK);
goto done;
}
@ -512,7 +512,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
bits = end - surface->pitch;
}
while (bits >= top && bits < end) {
if (SDL_RWread(src, bits, surface->pitch) != (size_t)surface->pitch) {
if (SDL_ReadRW(src, bits, surface->pitch) != (size_t)surface->pitch) {
goto done;
}
if (biBitCount == 8 && palette && biClrUsed < (1u << biBitCount)) {
@ -572,7 +572,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
done:
if (was_error) {
if (src) {
SDL_RWseek(src, fp_offset, SDL_RW_SEEK_SET);
SDL_SeekRW(src, fp_offset, SDL_RW_SEEK_SET);
}
SDL_DestroySurface(surface);
surface = NULL;
@ -703,11 +703,11 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst)
bfOffBits = 0; /* We'll write this when we're done */
/* Write the BMP file header values */
fp_offset = SDL_RWtell(dst);
fp_offset = SDL_TellRW(dst);
if (fp_offset < 0) {
goto done;
}
if (SDL_RWwrite(dst, magic, 2) != 2 ||
if (SDL_WriteRW(dst, magic, 2) != 2 ||
!SDL_WriteU32LE(dst, bfSize) ||
!SDL_WriteU16LE(dst, bfReserved1) ||
!SDL_WriteU16LE(dst, bfReserved2) ||
@ -801,14 +801,14 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst)
}
/* Write the bitmap offset */
bfOffBits = (Uint32)(SDL_RWtell(dst) - fp_offset);
if (SDL_RWseek(dst, fp_offset + 10, SDL_RW_SEEK_SET) < 0) {
bfOffBits = (Uint32)(SDL_TellRW(dst) - fp_offset);
if (SDL_SeekRW(dst, fp_offset + 10, SDL_RW_SEEK_SET) < 0) {
goto done;
}
if (!SDL_WriteU32LE(dst, bfOffBits)) {
goto done;
}
if (SDL_RWseek(dst, fp_offset + bfOffBits, SDL_RW_SEEK_SET) < 0) {
if (SDL_SeekRW(dst, fp_offset + bfOffBits, SDL_RW_SEEK_SET) < 0) {
goto done;
}
@ -817,7 +817,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst)
pad = ((bw % 4) ? (4 - (bw % 4)) : 0);
while (bits > (Uint8 *)intermediate_surface->pixels) {
bits -= intermediate_surface->pitch;
if (SDL_RWwrite(dst, bits, bw) != bw) {
if (SDL_WriteRW(dst, bits, bw) != bw) {
goto done;
}
if (pad) {
@ -831,18 +831,18 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst)
}
/* Write the BMP file size */
new_offset = SDL_RWtell(dst);
new_offset = SDL_TellRW(dst);
if (new_offset < 0) {
goto done;
}
bfSize = (Uint32)(new_offset - fp_offset);
if (SDL_RWseek(dst, fp_offset + 2, SDL_RW_SEEK_SET) < 0) {
if (SDL_SeekRW(dst, fp_offset + 2, SDL_RW_SEEK_SET) < 0) {
goto done;
}
if (!SDL_WriteU32LE(dst, bfSize)) {
goto done;
}
if (SDL_RWseek(dst, fp_offset + bfSize, SDL_RW_SEEK_SET) < 0) {
if (SDL_SeekRW(dst, fp_offset + bfSize, SDL_RW_SEEK_SET) < 0) {
goto done;
}

View File

@ -92,8 +92,8 @@ static void RWopsTearDown(void *arg)
/**
* Makes sure parameters work properly. Local helper function.
*
* \sa SDL_RWseek
* \sa SDL_RWread
* \sa SDL_SeekRW
* \sa SDL_ReadRW
*/
static void testGenericRWopsValidations(SDL_RWops *rw, SDL_bool write)
{
@ -106,35 +106,35 @@ static void testGenericRWopsValidations(SDL_RWops *rw, SDL_bool write)
SDL_zeroa(buf);
/* Set to start. */
i = SDL_RWseek(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
i = SDL_SeekRW(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_SeekRW succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_SeekRW (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
/* Test write */
s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString) - 1);
SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
s = SDL_WriteRW(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString) - 1);
SDLTest_AssertPass("Call to SDL_WriteRW succeeded");
if (write) {
SDLTest_AssertCheck(s == sizeof(RWopsHelloWorldTestString) - 1, "Verify result of writing with SDL_RWwrite, expected %i, got %i", (int)sizeof(RWopsHelloWorldTestString) - 1, (int)s);
SDLTest_AssertCheck(s == sizeof(RWopsHelloWorldTestString) - 1, "Verify result of writing with SDL_WriteRW, expected %i, got %i", (int)sizeof(RWopsHelloWorldTestString) - 1, (int)s);
} else {
SDLTest_AssertCheck(s == 0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int)s);
SDLTest_AssertCheck(s == 0, "Verify result of writing with SDL_WriteRW, expected: 0, got %i", (int)s);
}
/* Test seek to random position */
i = SDL_RWseek(rw, seekPos, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_RWseek (SDL_RW_SEEK_SET), expected %i, got %" SDL_PRIs64, seekPos, seekPos, i);
i = SDL_SeekRW(rw, seekPos, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_SeekRW succeeded");
SDLTest_AssertCheck(i == (Sint64)seekPos, "Verify seek to %i with SDL_SeekRW (SDL_RW_SEEK_SET), expected %i, got %" SDL_PRIs64, seekPos, seekPos, i);
/* Test seek back to start */
i = SDL_RWseek(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
i = SDL_SeekRW(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_SeekRW succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_SeekRW (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
/* Test read */
s = SDL_RWread(rw, buf, sizeof(RWopsHelloWorldTestString) - 1);
SDLTest_AssertPass("Call to SDL_RWread succeeded");
s = SDL_ReadRW(rw, buf, sizeof(RWopsHelloWorldTestString) - 1);
SDLTest_AssertPass("Call to SDL_ReadRW succeeded");
SDLTest_AssertCheck(
s == (sizeof(RWopsHelloWorldTestString) - 1),
"Verify result from SDL_RWread, expected %i, got %i",
"Verify result from SDL_ReadRW, expected %i, got %i",
(int)(sizeof(RWopsHelloWorldTestString) - 1),
(int)s);
SDLTest_AssertCheck(
@ -142,9 +142,9 @@ static void testGenericRWopsValidations(SDL_RWops *rw, SDL_bool write)
"Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
/* Test seek back to start */
i = SDL_RWseek(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
i = SDL_SeekRW(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_SeekRW succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_SeekRW (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
/* Test printf */
s = SDL_RWprintf(rw, "%s", RWopsHelloWorldTestString);
@ -152,20 +152,20 @@ static void testGenericRWopsValidations(SDL_RWops *rw, SDL_bool write)
if (write) {
SDLTest_AssertCheck(s == sizeof(RWopsHelloWorldTestString) - 1, "Verify result of writing with SDL_RWprintf, expected %i, got %i", (int)sizeof(RWopsHelloWorldTestString) - 1, (int)s);
} else {
SDLTest_AssertCheck(s == 0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int)s);
SDLTest_AssertCheck(s == 0, "Verify result of writing with SDL_WriteRW, expected: 0, got %i", (int)s);
}
/* Test seek back to start */
i = SDL_RWseek(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
i = SDL_SeekRW(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_SeekRW succeeded");
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_SeekRW (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
/* Test read */
s = SDL_RWread(rw, buf, sizeof(RWopsHelloWorldTestString) - 1);
SDLTest_AssertPass("Call to SDL_RWread succeeded");
s = SDL_ReadRW(rw, buf, sizeof(RWopsHelloWorldTestString) - 1);
SDLTest_AssertPass("Call to SDL_ReadRW succeeded");
SDLTest_AssertCheck(
s == (sizeof(RWopsHelloWorldTestString) - 1),
"Verify result from SDL_RWread, expected %i, got %i",
"Verify result from SDL_ReadRW, expected %i, got %i",
(int)(sizeof(RWopsHelloWorldTestString) - 1),
(int)s);
SDLTest_AssertCheck(
@ -173,28 +173,28 @@ static void testGenericRWopsValidations(SDL_RWops *rw, SDL_bool write)
"Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
/* More seek tests. */
i = SDL_RWseek(rw, -4, SDL_RW_SEEK_CUR);
SDLTest_AssertPass("Call to SDL_RWseek(...,-4,SDL_RW_SEEK_CUR) succeeded");
i = SDL_SeekRW(rw, -4, SDL_RW_SEEK_CUR);
SDLTest_AssertPass("Call to SDL_SeekRW(...,-4,SDL_RW_SEEK_CUR) succeeded");
SDLTest_AssertCheck(
i == (Sint64)(sizeof(RWopsHelloWorldTestString) - 5),
"Verify seek to -4 with SDL_RWseek (SDL_RW_SEEK_CUR), expected %i, got %i",
"Verify seek to -4 with SDL_SeekRW (SDL_RW_SEEK_CUR), expected %i, got %i",
(int)(sizeof(RWopsHelloWorldTestString) - 5),
(int)i);
i = SDL_RWseek(rw, -1, SDL_RW_SEEK_END);
SDLTest_AssertPass("Call to SDL_RWseek(...,-1,SDL_RW_SEEK_END) succeeded");
i = SDL_SeekRW(rw, -1, SDL_RW_SEEK_END);
SDLTest_AssertPass("Call to SDL_SeekRW(...,-1,SDL_RW_SEEK_END) succeeded");
SDLTest_AssertCheck(
i == (Sint64)(sizeof(RWopsHelloWorldTestString) - 2),
"Verify seek to -1 with SDL_RWseek (SDL_RW_SEEK_END), expected %i, got %i",
"Verify seek to -1 with SDL_SeekRW (SDL_RW_SEEK_END), expected %i, got %i",
(int)(sizeof(RWopsHelloWorldTestString) - 2),
(int)i);
/* Invalid whence seek */
i = SDL_RWseek(rw, 0, 999);
SDLTest_AssertPass("Call to SDL_RWseek(...,0,invalid_whence) succeeded");
i = SDL_SeekRW(rw, 0, 999);
SDLTest_AssertPass("Call to SDL_SeekRW(...,0,invalid_whence) succeeded");
SDLTest_AssertCheck(
i == (Sint64)(-1),
"Verify seek with SDL_RWseek (invalid_whence); expected: -1, got %i",
"Verify seek with SDL_SeekRW (invalid_whence); expected: -1, got %i",
(int)i);
}
@ -431,10 +431,10 @@ static int rwops_testCompareRWFromMemWithRWFromFile(void *arg)
/* Read/seek from memory */
rwops_mem = SDL_RWFromMem((void *)RWopsAlphabetString, slen);
SDLTest_AssertPass("Call to SDL_RWFromMem()");
rv_mem = SDL_RWread(rwops_mem, buffer_mem, size * 6);
SDLTest_AssertPass("Call to SDL_RWread(mem, size=%d)", size * 6);
sv_mem = SDL_RWseek(rwops_mem, 0, SEEK_END);
SDLTest_AssertPass("Call to SDL_RWseek(mem,SEEK_END)");
rv_mem = SDL_ReadRW(rwops_mem, buffer_mem, size * 6);
SDLTest_AssertPass("Call to SDL_ReadRW(mem, size=%d)", size * 6);
sv_mem = SDL_SeekRW(rwops_mem, 0, SEEK_END);
SDLTest_AssertPass("Call to SDL_SeekRW(mem,SEEK_END)");
result = SDL_CloseRW(rwops_mem);
SDLTest_AssertPass("Call to SDL_CloseRW(mem)");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
@ -442,10 +442,10 @@ static int rwops_testCompareRWFromMemWithRWFromFile(void *arg)
/* Read/see from file */
rwops_file = SDL_RWFromFile(RWopsAlphabetFilename, "r");
SDLTest_AssertPass("Call to SDL_RWFromFile()");
rv_file = SDL_RWread(rwops_file, buffer_file, size * 6);
SDLTest_AssertPass("Call to SDL_RWread(file, size=%d)", size * 6);
sv_file = SDL_RWseek(rwops_file, 0, SEEK_END);
SDLTest_AssertPass("Call to SDL_RWseek(file,SEEK_END)");
rv_file = SDL_ReadRW(rwops_file, buffer_file, size * 6);
SDLTest_AssertPass("Call to SDL_ReadRW(file, size=%d)", size * 6);
sv_file = SDL_SeekRW(rwops_file, 0, SEEK_END);
SDLTest_AssertPass("Call to SDL_SeekRW(file,SEEK_END)");
result = SDL_CloseRW(rwops_file);
SDLTest_AssertPass("Call to SDL_CloseRW(file)");
SDLTest_AssertCheck(result == 0, "Verify result value is 0; got: %d", result);
@ -559,9 +559,9 @@ static int rwops_testFileWriteReadEndian(void *arg)
SDLTest_AssertCheck(bresult == SDL_TRUE, "Validate object written, expected: SDL_TRUE, got: SDL_FALSE");
/* Test seek to start */
result = SDL_RWseek(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_RWseek, expected 0, got %i", (int)result);
result = SDL_SeekRW(rw, 0, SDL_RW_SEEK_SET);
SDLTest_AssertPass("Call to SDL_SeekRW succeeded");
SDLTest_AssertCheck(result == 0, "Verify result from position 0 with SDL_SeekRW, expected 0, got %i", (int)result);
/* Read test data */
bresult = SDL_ReadU16BE(rw, &BE16test);

View File

@ -155,19 +155,19 @@ int main(int argc, char *argv[])
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWwrite(rwops, "1234567", 7)) {
if (7 != SDL_WriteRW(rwops, "1234567", 7)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops); /* we are in write only mode */
}
@ -177,34 +177,34 @@ int main(int argc, char *argv[])
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (20 != SDL_RWseek(rwops, -7, SDL_RW_SEEK_END)) {
if (20 != SDL_SeekRW(rwops, -7, SDL_RW_SEEK_END)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWread(rwops, test_buf, 7)) {
if (7 != SDL_ReadRW(rwops, test_buf, 7)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1000)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1000)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, -27, SDL_RW_SEEK_CUR)) {
if (0 != SDL_SeekRW(rwops, -27, SDL_RW_SEEK_CUR)) {
RWOP_ERR_QUIT(rwops);
}
if (27 != SDL_RWread(rwops, test_buf, 30)) {
if (27 != SDL_ReadRW(rwops, test_buf, 30)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWwrite(rwops, test_buf, 1)) {
if (0 != SDL_WriteRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops); /* readonly mode */
}
@ -215,44 +215,44 @@ int main(int argc, char *argv[])
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWwrite(rwops, "1234567", 7)) {
if (7 != SDL_WriteRW(rwops, "1234567", 7)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (1 != SDL_RWread(rwops, test_buf, 1)) {
if (1 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (20 != SDL_RWseek(rwops, -7, SDL_RW_SEEK_END)) {
if (20 != SDL_SeekRW(rwops, -7, SDL_RW_SEEK_END)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWread(rwops, test_buf, 7)) {
if (7 != SDL_ReadRW(rwops, test_buf, 7)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1000)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1000)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, -27, SDL_RW_SEEK_CUR)) {
if (0 != SDL_SeekRW(rwops, -27, SDL_RW_SEEK_CUR)) {
RWOP_ERR_QUIT(rwops);
}
if (27 != SDL_RWread(rwops, test_buf, 30)) {
if (27 != SDL_ReadRW(rwops, test_buf, 30)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
@ -266,44 +266,44 @@ int main(int argc, char *argv[])
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWwrite(rwops, "1234567", 7)) {
if (7 != SDL_WriteRW(rwops, "1234567", 7)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (1 != SDL_RWread(rwops, test_buf, 1)) {
if (1 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops); /* we are in read/write mode */
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (20 != SDL_RWseek(rwops, -7, SDL_RW_SEEK_END)) {
if (20 != SDL_SeekRW(rwops, -7, SDL_RW_SEEK_END)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWread(rwops, test_buf, 7)) {
if (7 != SDL_ReadRW(rwops, test_buf, 7)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1000)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1000)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, -27, SDL_RW_SEEK_CUR)) {
if (0 != SDL_SeekRW(rwops, -27, SDL_RW_SEEK_CUR)) {
RWOP_ERR_QUIT(rwops);
}
if (27 != SDL_RWread(rwops, test_buf, 30)) {
if (27 != SDL_ReadRW(rwops, test_buf, 30)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "12345678901234567890", 20) != 0) {
@ -317,50 +317,50 @@ int main(int argc, char *argv[])
if (!rwops) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (10 != SDL_RWwrite(rwops, "1234567890", 10)) {
if (10 != SDL_WriteRW(rwops, "1234567890", 10)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWwrite(rwops, "1234567", 7)) {
if (7 != SDL_WriteRW(rwops, "1234567", 7)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (1 != SDL_RWread(rwops, test_buf, 1)) {
if (1 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (20 + 27 != SDL_RWseek(rwops, -7, SDL_RW_SEEK_END)) {
if (20 + 27 != SDL_SeekRW(rwops, -7, SDL_RW_SEEK_END)) {
RWOP_ERR_QUIT(rwops);
}
if (7 != SDL_RWread(rwops, test_buf, 7)) {
if (7 != SDL_ReadRW(rwops, test_buf, 7)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "1234567", 7) != 0) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWread(rwops, test_buf, 1000)) {
if (0 != SDL_ReadRW(rwops, test_buf, 1000)) {
RWOP_ERR_QUIT(rwops);
}
if (27 != SDL_RWseek(rwops, -27, SDL_RW_SEEK_CUR)) {
if (27 != SDL_SeekRW(rwops, -27, SDL_RW_SEEK_CUR)) {
RWOP_ERR_QUIT(rwops);
}
if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) {
if (0 != SDL_SeekRW(rwops, 0L, SDL_RW_SEEK_SET)) {
RWOP_ERR_QUIT(rwops);
}
if (30 != SDL_RWread(rwops, test_buf, 30)) {
if (30 != SDL_ReadRW(rwops, test_buf, 30)) {
RWOP_ERR_QUIT(rwops);
}
if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30) != 0) {

View File

@ -149,7 +149,7 @@ static int unifont_init(const char *fontname)
Uint8 glyphWidth;
Uint32 codepoint;
bytesRead = SDL_RWread(hexFile, hexBuffer, 9);
bytesRead = SDL_ReadRW(hexFile, hexBuffer, 9);
if (numGlyphs > 0 && bytesRead == 0) {
break; /* EOF */
}
@ -185,7 +185,7 @@ static int unifont_init(const char *fontname)
if (codepointHexSize < 8) {
SDL_memmove(hexBuffer, hexBuffer + codepointHexSize + 1, bytesOverread);
}
bytesRead = SDL_RWread(hexFile, hexBuffer + bytesOverread, 33 - bytesOverread);
bytesRead = SDL_ReadRW(hexFile, hexBuffer + bytesOverread, 33 - bytesOverread);
if (bytesRead < (33 - bytesOverread)) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
@ -195,7 +195,7 @@ static int unifont_init(const char *fontname)
glyphWidth = 8;
} else {
glyphWidth = 16;
bytesRead = SDL_RWread(hexFile, hexBuffer + 33, 32);
bytesRead = SDL_ReadRW(hexFile, hexBuffer + 33, 32);
if (bytesRead < 32) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Unexpected end of hex file.\n");
return -1;

View File

@ -450,7 +450,7 @@ int main(int argc, char **argv)
quit(2);
}
SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
SDL_ReadRW(handle, RawMooseData, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
SDL_CloseRW(handle);

View File

@ -139,7 +139,7 @@ int main(int argc, char **argv)
SDL_WriteU16LE(io, (Uint16)bitsize); /* significant bits per sample */
SDL_WriteU32LE(io, 0x61746164); /* data */
SDL_WriteU32LE(io, dst_len); /* size */
SDL_RWwrite(io, dst_buf, dst_len);
SDL_WriteRW(io, dst_buf, dst_len);
if (SDL_CloseRW(io) == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "closing '%s' failed: %s\n", file_out, SDL_GetError());

View File

@ -170,7 +170,7 @@ int main(int argc, char **argv)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
quit(2);
}
SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
SDL_ReadRW(handle, MooseFrames, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
SDL_CloseRW(handle);
/* Create the window and renderer */