mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-27 15:09:11 +00:00
iostream: Make seeking's whence
value a real enum.
This commit is contained in:
parent
35adef17a8
commit
7d54a37d74
3 changed files with 24 additions and 14 deletions
|
@ -56,6 +56,21 @@ typedef enum SDL_IOStatus
|
|||
SDL_IO_STATUS_WRITEONLY /**< Tried to read a write-only buffer */
|
||||
} SDL_IOStatus;
|
||||
|
||||
/**
|
||||
* Possible `whence` values for SDL_IOStream seeking.
|
||||
*
|
||||
* These map to the same "whence" concept that `fseek` or `lseek` use in
|
||||
* the standard C runtime.
|
||||
*
|
||||
* \since This enum is available since SDL 3.0.0.
|
||||
*/
|
||||
typedef enum SDL_IOWhence
|
||||
{
|
||||
SDL_IO_SEEK_SET, /**< Seek from the beginning of data */
|
||||
SDL_IO_SEEK_CUR, /**< Seek relative to current read point */
|
||||
SDL_IO_SEEK_END, /**< Seek relative to the end of data */
|
||||
} SDL_IOWhence;
|
||||
|
||||
/**
|
||||
* The function pointers that drive an SDL_IOStream.
|
||||
*
|
||||
|
@ -81,7 +96,7 @@ typedef struct SDL_IOStreamInterface
|
|||
*
|
||||
* \return the final offset in the data stream, or -1 on error.
|
||||
*/
|
||||
Sint64 (SDLCALL *seek)(void *userdata, Sint64 offset, int whence);
|
||||
Sint64 (SDLCALL *seek)(void *userdata, Sint64 offset, SDL_IOWhence whence);
|
||||
|
||||
/**
|
||||
* Read up to `size` bytes from the data stream to the area pointed
|
||||
|
@ -379,11 +394,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_CloseIO(SDL_IOStream *context);
|
|||
*/
|
||||
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetIOProperties(SDL_IOStream *context);
|
||||
|
||||
/* Possible `whence` values for SDL_IOStream seeking... */
|
||||
#define SDL_IO_SEEK_SET 0 /**< Seek from the beginning of data */
|
||||
#define SDL_IO_SEEK_CUR 1 /**< Seek relative to current read point */
|
||||
#define SDL_IO_SEEK_END 2 /**< Seek relative to the end of data */
|
||||
|
||||
/**
|
||||
* Query the stream status of an SDL_IOStream.
|
||||
*
|
||||
|
@ -431,7 +441,7 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context);
|
|||
* If this stream can not seek, it will return -1.
|
||||
*
|
||||
* \param context a pointer to an SDL_IOStream structure
|
||||
* \param offset an offset in bytes, relative to **whence** location; can be
|
||||
* \param offset an offset in bytes, relative to `whence` location; can be
|
||||
* negative
|
||||
* \param whence any of `SDL_IO_SEEK_SET`, `SDL_IO_SEEK_CUR`,
|
||||
* `SDL_IO_SEEK_END`
|
||||
|
@ -442,7 +452,7 @@ extern SDL_DECLSPEC Sint64 SDLCALL SDL_GetIOSize(SDL_IOStream *context);
|
|||
*
|
||||
* \sa SDL_TellIO
|
||||
*/
|
||||
extern SDL_DECLSPEC Sint64 SDLCALL SDL_SeekIO(SDL_IOStream *context, Sint64 offset, int whence);
|
||||
extern SDL_DECLSPEC Sint64 SDLCALL SDL_SeekIO(SDL_IOStream *context, Sint64 offset, SDL_IOWhence whence);
|
||||
|
||||
/**
|
||||
* Determine the current read/write offset in an SDL_IOStream data stream.
|
||||
|
|
|
@ -709,7 +709,7 @@ SDL_DYNAPI_PROC(int,SDL_SaveBMP,(SDL_Surface *a, const char *b),(a,b),return)
|
|||
SDL_DYNAPI_PROC(int,SDL_SaveBMP_IO,(SDL_Surface *a, SDL_IOStream *b, SDL_bool c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenKeyboardShown,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenSaverEnabled,(void),(),return)
|
||||
SDL_DYNAPI_PROC(Sint64,SDL_SeekIO,(SDL_IOStream *a, Sint64 b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(Sint64,SDL_SeekIO,(SDL_IOStream *a, Sint64 b, SDL_IOWhence c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SendGamepadEffect,(SDL_Gamepad *a, const void *b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SendJoystickEffect,(SDL_Joystick *a, const void *b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SendJoystickVirtualSensorData,(SDL_Joystick *a, SDL_SensorType b, Uint64 c, const float *d, int e),(a,b,c,d,e),return)
|
||||
|
|
|
@ -171,7 +171,7 @@ static Sint64 SDLCALL windows_file_size(void *userdata)
|
|||
return size.QuadPart;
|
||||
}
|
||||
|
||||
static Sint64 SDLCALL windows_file_seek(void *userdata, Sint64 offset, int whence)
|
||||
static Sint64 SDLCALL windows_file_seek(void *userdata, Sint64 offset, SDL_IOWhence whence)
|
||||
{
|
||||
IOStreamWindowsData *iodata = (IOStreamWindowsData *) userdata;
|
||||
DWORD windowswhence;
|
||||
|
@ -339,7 +339,7 @@ typedef struct IOStreamStdioData
|
|||
#define fseek_off_t long
|
||||
#endif
|
||||
|
||||
static Sint64 SDLCALL stdio_seek(void *userdata, Sint64 offset, int whence)
|
||||
static Sint64 SDLCALL stdio_seek(void *userdata, Sint64 offset, SDL_IOWhence whence)
|
||||
{
|
||||
IOStreamStdioData *iodata = (IOStreamStdioData *) userdata;
|
||||
int stdiowhence;
|
||||
|
@ -454,7 +454,7 @@ static Sint64 SDLCALL mem_size(void *userdata)
|
|||
return (iodata->stop - iodata->base);
|
||||
}
|
||||
|
||||
static Sint64 SDLCALL mem_seek(void *userdata, Sint64 offset, int whence)
|
||||
static Sint64 SDLCALL mem_seek(void *userdata, Sint64 offset, SDL_IOWhence whence)
|
||||
{
|
||||
IOStreamMemData *iodata = (IOStreamMemData *) userdata;
|
||||
Uint8 *newpos;
|
||||
|
@ -760,7 +760,7 @@ static Sint64 SDLCALL dynamic_mem_size(void *userdata)
|
|||
return mem_size(&iodata->data);
|
||||
}
|
||||
|
||||
static Sint64 SDLCALL dynamic_mem_seek(void *userdata, Sint64 offset, int whence)
|
||||
static Sint64 SDLCALL dynamic_mem_seek(void *userdata, Sint64 offset, SDL_IOWhence whence)
|
||||
{
|
||||
IOStreamDynamicMemData *iodata = (IOStreamDynamicMemData *) userdata;
|
||||
return mem_seek(&iodata->data, offset, whence);
|
||||
|
@ -993,7 +993,7 @@ Sint64 SDL_GetIOSize(SDL_IOStream *context)
|
|||
return context->iface.size(context->userdata);
|
||||
}
|
||||
|
||||
Sint64 SDL_SeekIO(SDL_IOStream *context, Sint64 offset, int whence)
|
||||
Sint64 SDL_SeekIO(SDL_IOStream *context, Sint64 offset, SDL_IOWhence whence)
|
||||
{
|
||||
if (!context) {
|
||||
return SDL_InvalidParamError("context");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue