filesystem topic

CategoryFilesystem

SDL offers an API for examining and manipulating the system's filesystem. This covers most things one would need to do with directories, except for actual file I/O (which is covered by CategoryIOStream and CategoryAsyncIO instead).

There are functions to answer necessary path questions:

  • Where is my app's data? SDL_GetBasePath().
  • Where can I safely write files? SDL_GetPrefPath().
  • Where are paths like Downloads, Desktop, Music? SDL_GetUserFolder().
  • What is this thing at this location? SDL_GetPathInfo().
  • What items live in this folder? SDL_EnumerateDirectory().
  • What items live in this folder by wildcard? SDL_GlobDirectory().
  • What is my current working directory? SDL_GetCurrentDirectory().

SDL also offers functions to manipulate the directory tree: renaming, removing, copying files.

Functions

sdlCopyFile(String? oldpath, String? newpath) bool filesystem
Copy a file.
sdlCreateDirectory(String? path) bool filesystem
Create a directory, and any missing parent directories.
sdlEnumerateDirectory(String? path, Pointer<NativeFunction<SdlEnumerateDirectoryCallback>> callback, Pointer<NativeType> userdata) bool filesystem
Enumerate a directory through a callback function.
sdlGetBasePath() String? filesystem
Get the directory where the application was run from.
sdlGetCurrentDirectory() Pointer<Int8> filesystem
Get what the system believes is the "current working directory."
sdlGetPathInfo(String? path, Pointer<SdlPathInfo> info) bool filesystem
Get information about a filesystem path.
sdlGetPrefPath(String? org, String? app) Pointer<Int8> filesystem
Get the user-and-app-specific path where files can be written.
sdlGetUserFolder(int folder) String? filesystem
Finds the most suitable user folder for a specific purpose.
sdlGlobDirectory(String? path, String? pattern, int flags, Pointer<Int32> count) Pointer<Pointer<Int8>> filesystem
Enumerate a directory tree, filtered by pattern, and return a list.
sdlRemovePath(String? path) bool filesystem
Remove a file or an empty directory.
sdlRenamePath(String? oldpath, String? newpath) bool filesystem
Rename a file or directory.