sdlLoadFile function
Load all the data from a file path.
The data is allocated with a zero byte at the end (null terminated) for
convenience. This extra byte is not included in the value reported via
datasize
.
The data should be freed with SDL_free().
\param file the path to read all available data from. \param datasize if not NULL, will store the number of bytes read. \returns the data or NULL on failure; call SDL_GetError() for more information.
\since This function is available since SDL 3.1.3.
\sa SDL_LoadFile_IO \sa SDL_SaveFile
extern SDL_DECLSPEC void * SDLCALL SDL_LoadFile(const char *file, size_t *datasize)
Implementation
Pointer<NativeType> sdlLoadFile(String? file, Pointer<Uint32> datasize) {
final sdlLoadFileLookupFunction = libSdl3.lookupFunction<
Pointer<NativeType> Function(
Pointer<Utf8> file, Pointer<Uint32> datasize),
Pointer<NativeType> Function(
Pointer<Utf8> file, Pointer<Uint32> datasize)>('SDL_LoadFile');
final filePointer = file != null ? file.toNativeUtf8() : nullptr;
final result = sdlLoadFileLookupFunction(filePointer, datasize);
calloc.free(filePointer);
return result;
}