Scroll to navigation

SDL_RWread(3) SDL3 FUNCTIONS SDL_RWread(3)

NAME

SDL_RWread - Read from a data source.

SYNOPSIS

#include "SDL3/SDL.h"
size_t SDL_RWread(SDL_RWops *context, void *ptr, size_t size);

DESCRIPTION

This function reads up size bytes from the data source to the area pointed at by ptr . This function may read less bytes than requested. It will return zero when the data stream is completely read, or -1 on error. For streams that support non-blocking operation, if nothing was read because it would require blocking, this function returns -2 to distinguish 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 read method appropriately, to simplify application development.

It is an error to specify a negative size , but this parameter is signed so you definitely cannot overflow the return value on a successful run with enormous amounts of data.

FUNCTION PARAMETERS

a pointer to an SDL_RWops
structure
a pointer to a buffer to read data into
the number of bytes to read from the data source.

RETURN VALUE

Returns the number of bytes read, or 0 on end of file or other error.

AVAILABILITY

This function is available since SDL 3.0.0.

SEE ALSO

SDL_RWclose(3), SDL_RWFromConstMem(3), SDL_RWFromFile(3), SDL_RWFromMem(3), SDL_RWseek(3), SDL_RWwrite(3)

SDL 3.0.0 SDL