mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-24 16:25:49 +00:00
rwops: Rename everything from SDL_RWxxx to SDL_XxxRW.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user