sdlReadIo function iostream

int sdlReadIo(
  1. Pointer<SdlIoStream> context,
  2. Pointer<NativeType> ptr,
  3. int size
)

Read from a data source.

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.

This function will return zero when the data stream is completely read, and SDL_GetIOStatus() will return SDL_IO_STATUS_EOF. If zero is returned and the stream is not at EOF, SDL_GetIOStatus() will return a different error value and SDL_GetError() will offer a human-readable message.

A request for zero bytes on a valid stream will return zero immediately without accessing the stream, so the stream status (EOF, err, etc) will not change.

\param context a pointer to an SDL_IOStream structure. \param ptr a pointer to a buffer to read data into. \param size the number of bytes to read from the data source. \returns the number of bytes read, or 0 on end of file or other failure; call SDL_GetError() for more information.

\threadsafety Do not use the same SDL_IOStream from two threads at once.

\since This function is available since SDL 3.2.0.

\sa SDL_WriteIO \sa SDL_GetIOStatus

extern SDL_DECLSPEC size_t SDLCALL SDL_ReadIO(SDL_IOStream *context, void *ptr, size_t size)

Implementation

int sdlReadIo(Pointer<SdlIoStream> context, Pointer<NativeType> ptr, int size) {
  final sdlReadIoLookupFunction = _libSdl
      .lookupFunction<
        Uint32 Function(
          Pointer<SdlIoStream> context,
          Pointer<NativeType> ptr,
          Uint32 size,
        ),
        int Function(
          Pointer<SdlIoStream> context,
          Pointer<NativeType> ptr,
          int size,
        )
      >('SDL_ReadIO');
  return sdlReadIoLookupFunction(context, ptr, size);
}