sdlReadStorageFile function

bool sdlReadStorageFile(
  1. Pointer<SdlStorage> storage,
  2. String? path,
  3. Pointer<NativeType> destination,
  4. int length,
)

Synchronously read a file from a storage container into a client-provided buffer.

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

\since This function is available since SDL 3.1.3.

\sa SDL_GetStorageFileSize \sa SDL_StorageReady \sa SDL_WriteStorageFile

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

Implementation

bool sdlReadStorageFile(Pointer<SdlStorage> storage, String? path,
    Pointer<NativeType> destination, int length) {
  final sdlReadStorageFileLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<SdlStorage> storage, Pointer<Utf8> path,
          Pointer<NativeType> destination, Uint64 length),
      int Function(Pointer<SdlStorage> storage, Pointer<Utf8> path,
          Pointer<NativeType> destination, int length)>('SDL_ReadStorageFile');
  final pathPointer = path != null ? path.toNativeUtf8() : nullptr;
  final result = sdlReadStorageFileLookupFunction(
          storage, pathPointer, destination, length) ==
      1;
  calloc.free(pathPointer);
  return result;
}