mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-09-22 03:04:51 +08:00
SDL_rwops read/write functions return size_t again
The current status is stored in the SDL_rwops 'status' field to be able to determine whether a 0 return value is caused by end of file, an error, or a non-blocking source not being ready. The functions to read sized datatypes now return SDL_bool so you can detect read errors. Fixes https://github.com/libsdl-org/SDL/issues/6729
This commit is contained in:
@@ -176,7 +176,8 @@ extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
|
||||
* constrained environment.
|
||||
*
|
||||
* \param src the data stream for the mappings to be added
|
||||
* \param freesrc non-zero to close the stream after being read
|
||||
* \param freesrc if SDL_TRUE, calls SDL_RWclose() on `src` before returning,
|
||||
* even in the case of an error
|
||||
* \returns the number of mappings added or -1 on error; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
@@ -186,7 +187,7 @@ extern DECLSPEC int SDLCALL SDL_AddGamepadMapping(const char *mapping);
|
||||
* \sa SDL_AddGamepadMappingsFromFile
|
||||
* \sa SDL_GetGamepadMappingForGUID
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromRW(SDL_RWops *src, int freesrc);
|
||||
extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc);
|
||||
|
||||
/**
|
||||
* Load a set of gamepad mappings from a file.
|
||||
|
||||
@@ -423,6 +423,18 @@
|
||||
#define RW_SEEK_SET SDL_RW_SEEK_SET
|
||||
#define SDL_AllocRW SDL_CreateRW
|
||||
#define SDL_FreeRW SDL_DestroyRW
|
||||
#define SDL_ReadBE16 SDL_ReadU16BE
|
||||
#define SDL_ReadBE32 SDL_ReadU32BE
|
||||
#define SDL_ReadBE64 SDL_ReadU64BE
|
||||
#define SDL_ReadLE16 SDL_ReadU16LE
|
||||
#define SDL_ReadLE32 SDL_ReadU32LE
|
||||
#define SDL_ReadLE64 SDL_ReadU64LE
|
||||
#define SDL_WriteBE16 SDL_WriteU16BE
|
||||
#define SDL_WriteBE32 SDL_WriteU32BE
|
||||
#define SDL_WriteBE64 SDL_WriteU64BE
|
||||
#define SDL_WriteLE16 SDL_WriteU16LE
|
||||
#define SDL_WriteLE32 SDL_WriteU32LE
|
||||
#define SDL_WriteLE64 SDL_WriteU64LE
|
||||
|
||||
/* ##SDL_sensor.h */
|
||||
#define SDL_SensorClose SDL_CloseSensor
|
||||
@@ -863,6 +875,18 @@
|
||||
#define RW_SEEK_SET RW_SEEK_SET_renamed_SDL_RW_SEEK_SET
|
||||
#define SDL_AllocRW SDL_AllocRW_renamed_SDL_CreateRW
|
||||
#define SDL_FreeRW SDL_FreeRW_renamed_SDL_DestroyRW
|
||||
#define SDL_ReadBE16 SDL_ReadBE16_renamed_SDL_ReadU16BE
|
||||
#define SDL_ReadBE32 SDL_ReadBE32_renamed_SDL_ReadU32BE
|
||||
#define SDL_ReadBE64 SDL_ReadBE64_renamed_SDL_ReadU64BE
|
||||
#define SDL_ReadLE16 SDL_ReadLE16_renamed_SDL_ReadU16LE
|
||||
#define SDL_ReadLE32 SDL_ReadLE32_renamed_SDL_ReadU32LE
|
||||
#define SDL_ReadLE64 SDL_ReadLE64_renamed_SDL_ReadU64LE
|
||||
#define SDL_WriteBE16 SDL_WriteBE16_renamed_SDL_WriteU16BE
|
||||
#define SDL_WriteBE32 SDL_WriteBE32_renamed_SDL_WriteU32BE
|
||||
#define SDL_WriteBE64 SDL_WriteBE64_renamed_SDL_WriteU64BE
|
||||
#define SDL_WriteLE16 SDL_WriteLE16_renamed_SDL_WriteU16LE
|
||||
#define SDL_WriteLE32 SDL_WriteLE32_renamed_SDL_WriteU32LE
|
||||
#define SDL_WriteLE64 SDL_WriteLE64_renamed_SDL_WriteU64LE
|
||||
|
||||
/* ##SDL_sensor.h */
|
||||
#define SDL_SensorClose SDL_SensorClose_renamed_SDL_CloseSensor
|
||||
|
||||
+277
-136
File diff suppressed because it is too large
Load Diff
@@ -273,7 +273,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP(const char *file);
|
||||
*
|
||||
* \param surface the SDL_Surface structure containing the image to be saved
|
||||
* \param dst a data stream to save to
|
||||
* \param freedst non-zero to close the stream after being written
|
||||
* \param freedst if SDL_TRUE, calls SDL_RWclose() on `dst` before returning,
|
||||
* even in the case of an error
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -282,7 +283,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP(const char *file);
|
||||
* \sa SDL_LoadBMP_RW
|
||||
* \sa SDL_SaveBMP
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst);
|
||||
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst);
|
||||
|
||||
/**
|
||||
* Save a surface to a file.
|
||||
|
||||
Reference in New Issue
Block a user