sdlGetUserFolder function

String? sdlGetUserFolder(
  1. int folder
)

Finds the most suitable user folder for a specific purpose.

Many OSes provide certain standard folders for certain purposes, such as storing pictures, music or videos for a certain user. This function gives the path for many of those special locations.

This function is specifically for user folders, which are meant for the user to access and manage. For application-specific folders, meant to hold data for the application to manage, see SDL_GetBasePath() and SDL_GetPrefPath().

The returned path is guaranteed to end with a path separator ('\' on Windows, '/' on most other platforms).

If NULL is returned, the error may be obtained with SDL_GetError().

\param folder the type of folder to find. \returns either a null-terminated C string containing the full path to the folder, or NULL if an error happened.

\since This function is available since SDL 3.1.3.

extern SDL_DECLSPEC const char * SDLCALL SDL_GetUserFolder(SDL_Folder folder)

Implementation

String? sdlGetUserFolder(int folder) {
  final sdlGetUserFolderLookupFunction = libSdl3.lookupFunction<
      Pointer<Utf8> Function(Int32 folder),
      Pointer<Utf8> Function(int folder)>('SDL_GetUserFolder');
  final result = sdlGetUserFolderLookupFunction(folder);
  if (result == nullptr) {
    return null;
  }
  return result.toDartString();
}