SDL_IOStreamInterface Struct Reference

`#include <SDL_iostream.h>`

## Data Fields

Uint32 | version
Sint64(* | size )(void *userdata)
Sint64(* | seek )(void *userdata, Sint64 offset, SDL_IOWhence whence)
size_t(* | read )(void *userdata, void *ptr, size_t size, SDL_IOStatus *status)
size_t(* | write )(void *userdata, const void *ptr, size_t size, SDL_IOStatus *status)
bool(* | flush )(void *userdata, SDL_IOStatus *status)
bool(* | close )(void *userdata)

## Detailed Description

The function pointers that drive an SDL_IOStream.

Applications can provide this struct to SDL_OpenIO() to create their own implementation of SDL_IOStream. This is not necessarily required, as SDL already offers several common types of I/O streams, via functions like SDL_IOFromFile() and SDL_IOFromMem().

This structure should be initialized using SDL_INIT_INTERFACE()

Since
  This struct is available since SDL 3.2.0.

See also
  SDL_INIT_INTERFACE

Definition at line 92 of file SDL_iostream.h.

## Field Documentation

## close

bool(* SDL_IOStreamInterface::close) (void *userdata)

Close and free any allocated resources.

This does not guarantee file writes will sync to physical media; they can be in the system's file cache, waiting to go to disk.

The SDL_IOStream is still destroyed even if this fails, so clean up anything even if flushing buffers, etc, returns an error.

Returns
  true if successful or false on write error when flushing data.

Definition at line 158 of file SDL_iostream.h.

## flush

bool(* SDL_IOStreamInterface::flush) (void *userdata, SDL_IOStatus *status)

If the stream is buffering, make sure the data is written out.

On failure, you should set `*status` to a value from the SDL_IOStatus enum. You do not have to explicitly set this on a successful flush.

Returns
  true if successful or false on write error when flushing data.

Definition at line 145 of file SDL_iostream.h.

## read

size_t(* SDL_IOStreamInterface::read) (void *userdata, void *ptr, size_t size, SDL_IOStatus *status)

Read up to `size` bytes from the data stream to the area pointed at by `ptr`.

On an incomplete read, you should set `*status` to a value from the SDL_IOStatus enum. You do not have to explicitly set this on a complete, successful read.

Returns
  the number of bytes read

Definition at line 122 of file SDL_iostream.h.

## seek

Sint64(* SDL_IOStreamInterface::seek) (void *userdata, Sint64 offset, SDL_IOWhence whence)

Seek to `offset` relative to `whence`, one of stdio's whence values: SDL_IO_SEEK_SET, SDL_IO_SEEK_CUR, SDL_IO_SEEK_END

Returns
  the final offset in the data stream, or -1 on error.

Definition at line 110 of file SDL_iostream.h.

## size

Sint64(* SDL_IOStreamInterface::size) (void *userdata)

Return the number of bytes in this SDL_IOStream

Returns
  the total size of the data stream, or -1 on error.

Definition at line 102 of file SDL_iostream.h.

## version

Uint32 SDL_IOStreamInterface::version

Definition at line 95 of file SDL_iostream.h.

## write

size_t(* SDL_IOStreamInterface::write) (void *userdata, const void *ptr, size_t size, SDL_IOStatus *status)

Write exactly `size` bytes from the area pointed at by `ptr` to data stream.

On an incomplete write, you should set `*status` to a value from the SDL_IOStatus enum. You do not have to explicitly set this on a complete, successful write.

Returns
  the number of bytes written

Definition at line 134 of file SDL_iostream.h.

The documentation for this struct was generated from the following file:

- SDL_iostream.h