sdlWriteIo function

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

Write to an SDL_IOStream data stream.

This function writes exactly size bytes from the area pointed at by ptr to the stream. If this fails for any reason, it'll return less than size to demonstrate how far the write progressed. On success, it returns size.

On error, this function still attempts to write as much as possible, so it might return a positive value less than the requested write size.

The caller can use SDL_GetIOStatus() to determine if the problem is recoverable, such as a non-blocking write that can simply be retried later, or a fatal error.

\param context a pointer to an SDL_IOStream structure. \param ptr a pointer to a buffer containing data to write. \param size the number of bytes to write. \returns the number of bytes written, which will be less than size on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.1.3.

\sa SDL_IOprintf \sa SDL_ReadIO \sa SDL_SeekIO \sa SDL_FlushIO \sa SDL_GetIOStatus

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

Implementation

int sdlWriteIo(
    Pointer<SdlIoStream> context, Pointer<NativeType> ptr, int size) {
  final sdlWriteIoLookupFunction = libSdl3.lookupFunction<
      Uint32 Function(
          Pointer<SdlIoStream> context, Pointer<NativeType> ptr, Uint32 size),
      int Function(Pointer<SdlIoStream> context, Pointer<NativeType> ptr,
          int size)>('SDL_WriteIO');
  return sdlWriteIoLookupFunction(context, ptr, size);
}