sdlxWriteStorageFile function storage

bool sdlxWriteStorageFile(
  1. Pointer<SdlStorage> storage,
  2. String path,
  3. Uint8List source
)

Synchronously write a file from client memory into a storage container.

\param storage a storage container to write to. \param path the relative path of the file to write. \param source a client-provided buffer to write from. \param length the length of the source buffer. \returns true if the file was written or false on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.2.0.

\sa SDL_GetStorageSpaceRemaining \sa SDL_ReadStorageFile \sa SDL_StorageReady

extern SDL_DECLSPEC bool SDLCALL SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void *source, Uint64 length)

Implementation

bool sdlxWriteStorageFile(
  Pointer<SdlStorage> storage,
  String path,
  Uint8List source,
) {
  final sourcePointer = ffi.calloc<Uint8>(source.length);
  sourcePointer.asTypedList(source.length).setRange(0, source.length, source);
  final bl = sdlWriteStorageFile(
    storage,
    path,
    sourcePointer.cast<Void>(),
    source.length,
  );
  sourcePointer.callocFree();
  return bl;
}