sdlSaveFile function

bool sdlSaveFile(
  1. String? file,
  2. Pointer<NativeType> data,
  3. int datasize
)

Save all the data into a file path.

\param file the path to read all available data from. \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. \returns true on success or false on failure; call SDL_GetError() for more information.

\since This function is available since SDL 3.2.0.

\sa SDL_SaveFile_IO \sa SDL_LoadFile

extern SDL_DECLSPEC bool SDLCALL SDL_SaveFile(const char *file, const void *data, size_t datasize)

Implementation

bool sdlSaveFile(String? file, Pointer<NativeType> data, int datasize) {
  final sdlSaveFileLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(
          Pointer<Utf8> file, Pointer<NativeType> data, Uint32 datasize),
      int Function(Pointer<Utf8> file, Pointer<NativeType> data,
          int datasize)>('SDL_SaveFile');
  final filePointer = file != null ? file.toNativeUtf8() : nullptr;
  final result = sdlSaveFileLookupFunction(filePointer, data, datasize) == 1;
  calloc.free(filePointer);
  return result;
}