sdlLoadFile function iostream
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.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.2.0.
\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 = _libSdl
.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;
}