sdlxSaveFileIo function iostream

bool sdlxSaveFileIo(
  1. Pointer<SdlIoStream> src,
  2. Uint8List data, {
  3. bool closeio = false,
})

Save all the data into an SDL data stream.

\param src the SDL_IOStream to write all data to. \param data the data to be written. If datasize is 0, may be NULL or a invalid pointer. \param datasize the number of bytes to be written. \param closeio if true, calls SDL_CloseIO() on src before returning, even in the case of an error. \returns true on success or false on 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_SaveFile \sa SDL_LoadFile_IO

extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile_IO(SDL_IOStream *src, const void *data, size_t datasize, bool closeio)

Implementation

bool sdlxSaveFileIo(
  Pointer<SdlIoStream> src,
  Uint8List data, {
  bool closeio = false,
}) {
  final dataPointer = ffi.calloc<Uint8>(data.length);
  dataPointer.asTypedList(data.length).setAll(0, data);
  final result = sdlSaveFileIo(
    src,
    dataPointer.cast<Void>(),
    data.length,
    closeio,
  );
  dataPointer.callocFree();
  return result;
}