| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Filesystem
Contents
Description
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?
.getBasePath - Where can I safely write files?
.getPrefPath - Where are paths like Downloads, Desktop, Music?
.getUserFolder - What is this thing at this location?
.getPathInfo - What items live in this folder?
.enumerateDirectorySafe - What items live in this folder by wildcard?
.globDirectory - What is my current working directory?
.getCurrentDirectory
SDL also offers functions to manipulate the directory tree: renaming, removing, copying files. Get the directory where the application was run from.
SDL caches the result of this call internally, but the first call to this function is not necessarily fast, so plan accordingly.
macOS and iOS Specific Functionality: If the application is in a ".app" bundle, this function returns the Resource directory (e.g. MyApp.app/Contents/Resources/). This behaviour can be overridden by adding a property to the Info.plist file. Adding a string key with the name SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the behaviour.
Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an application in /Applications/SDLApp/MyApp.app):
resource: bundle resource directory (the default). For example:/Applications/SDLApp/MyApp.app/Contents/Resourcesbundle: the Bundle directory. For example:/Applications/SDLApp/MyApp.app/parent: the containing directory of the bundle. For example:/Applications/SDLApp/
Android Specific Functionality: This function returns "./", which allows filesystem operations to use internal storage and the asset system.
Nintendo 3DS Specific Functionality: This function returns "romfs" directory of the application as it is uncommon to store resources outside the executable. As such it is not a writable directory.
The returned path is guaranteed to end with a path separator ('\' on Windows, '/' on most other platforms).
- Returns
- an absolute path in UTF-8 encoding to the application data directory. NULL will be returned on error or when the platform doesn't implement this functionality, call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
getPrefPath
FFI conventions
Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Filesystem.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.
Full conventions: SDL3.Sys.
Since: 3.2.0
Synopsis
- module SDL3.Sys.Bindgen.Filesystem
- pattern SDL_GLOB_CASEINSENSITIVE :: SDL_GlobFlags
- getBasePath :: IO (PtrConst CChar)
- getBasePathSafe :: IO (PtrConst CChar)
- getPrefPath :: PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)
- getPrefPathSafe :: PtrConst CChar -> PtrConst CChar -> IO (Ptr CChar)
- getUserFolder :: SDL_Folder -> IO (PtrConst CChar)
- getUserFolderSafe :: SDL_Folder -> IO (PtrConst CChar)
- createDirectory :: PtrConst CChar -> IO Bool
- createDirectorySafe :: PtrConst CChar -> IO Bool
- enumerateDirectorySafe :: PtrConst CChar -> SDL_EnumerateDirectoryCallback -> Ptr Void -> IO Bool
- removePath :: PtrConst CChar -> IO Bool
- removePathSafe :: PtrConst CChar -> IO Bool
- renamePath :: PtrConst CChar -> PtrConst CChar -> IO Bool
- renamePathSafe :: PtrConst CChar -> PtrConst CChar -> IO Bool
- copyFile :: PtrConst CChar -> PtrConst CChar -> IO Bool
- copyFileSafe :: PtrConst CChar -> PtrConst CChar -> IO Bool
- getPathInfo :: PtrConst CChar -> Ptr SDL_PathInfo -> IO Bool
- getPathInfoSafe :: PtrConst CChar -> Ptr SDL_PathInfo -> IO Bool
- globDirectory :: PtrConst CChar -> PtrConst CChar -> SDL_GlobFlags -> Ptr CInt -> IO (Ptr (Ptr CChar))
- globDirectorySafe :: PtrConst CChar -> PtrConst CChar -> SDL_GlobFlags -> Ptr CInt -> IO (Ptr (Ptr CChar))
- getCurrentDirectory :: IO (Ptr CChar)
- getCurrentDirectorySafe :: IO (Ptr CChar)
Documentation
module SDL3.Sys.Bindgen.Filesystem
Typed constants
pattern SDL_GLOB_CASEINSENSITIVE :: SDL_GlobFlags Source #
Typed constant for macro SDL_GLOB_CASEINSENSITIVE. Combine with .|. from Data.Bits.
Function aliases
getBasePath :: IO (PtrConst CChar) Source #
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetBasePath. The safe flavor isgetBasePathSafe. - C declaration
SDL_GetBasePath, defined atSDL3/SDL_filesystem.h 101:42
getBasePathSafe :: IO (PtrConst CChar) Source #
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetBasePath. The unsafe flavor isgetBasePath. - C declaration
SDL_GetBasePath, defined atSDL3/SDL_filesystem.h 101:42
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> IO (Ptr CChar) |
Get the user-and-app-specific path where files can be written.
Get the "pref dir". This is meant to be where users can write personal files (preferences and save games, etc) that are specific to your application. This directory is unique per user, per application.
This function will decide the appropriate location in the native filesystem, create the directory if necessary, and return a string of the absolute path to the directory in UTF-8 encoding.
On Windows, the string might look like:
C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\
On Linux, the string might look like:
/home/bob/.local/share/My Program Name/
On macOS, the string might look like:
/Users/bob/Library/Application Support/My Program Name/
You should assume the path returned by this function is the only safe place to write files (and that , while it might be writable, or even the parent of the returned path, isn't where you should be writing things).getBasePath
Both the org and app strings may become part of a directory name, so please follow these rules:
- Try to use the same org string (including case-sensitivity) for all your applications that use this function.
- Always use a unique app string for each one, and make sure it never changes for an app once you've decided on it.
- Unicode characters are legal, as long as they are UTF-8 encoded, but...
- ...only use letters, numbers, and spaces. Avoid punctuation like "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
Due to historical mistakes, org is allowed to be NULL or "". In such cases, SDL will omit the org subdirectory, including on platforms where it shouldn't, and including on platforms where this would make your app fail certification for an app store. New apps should definitely specify a real string for org.
The returned path is guaranteed to end with a path separator ('\' on Windows, '/' on most other platforms).
- Returns
- a UTF-8 string of the user directory in platform-dependent notation. NULL if there's a problem (creating directory failed, etc.). This should be freed with
freewhen it is no longer needed. - Thread safety
- It is safe to call this function from any thread.
- See also
getBasePath
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetPrefPath. The safe flavor isgetPrefPathSafe. - C declaration
SDL_GetPrefPath, defined atSDL3/SDL_filesystem.h 164:36
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> IO (Ptr CChar) |
Get the user-and-app-specific path where files can be written.
Get the "pref dir". This is meant to be where users can write personal files (preferences and save games, etc) that are specific to your application. This directory is unique per user, per application.
This function will decide the appropriate location in the native filesystem, create the directory if necessary, and return a string of the absolute path to the directory in UTF-8 encoding.
On Windows, the string might look like:
C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\
On Linux, the string might look like:
/home/bob/.local/share/My Program Name/
On macOS, the string might look like:
/Users/bob/Library/Application Support/My Program Name/
You should assume the path returned by this function is the only safe place to write files (and that , while it might be writable, or even the parent of the returned path, isn't where you should be writing things).getBasePath
Both the org and app strings may become part of a directory name, so please follow these rules:
- Try to use the same org string (including case-sensitivity) for all your applications that use this function.
- Always use a unique app string for each one, and make sure it never changes for an app once you've decided on it.
- Unicode characters are legal, as long as they are UTF-8 encoded, but...
- ...only use letters, numbers, and spaces. Avoid punctuation like "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
Due to historical mistakes, org is allowed to be NULL or "". In such cases, SDL will omit the org subdirectory, including on platforms where it shouldn't, and including on platforms where this would make your app fail certification for an app store. New apps should definitely specify a real string for org.
The returned path is guaranteed to end with a path separator ('\' on Windows, '/' on most other platforms).
- Returns
- a UTF-8 string of the user directory in platform-dependent notation. NULL if there's a problem (creating directory failed, etc.). This should be freed with
freewhen it is no longer needed. - Thread safety
- It is safe to call this function from any thread.
- See also
getBasePath
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetPrefPath. The unsafe flavor isgetPrefPath. - C declaration
SDL_GetPrefPath, defined atSDL3/SDL_filesystem.h 164:36
Since: 3.2.0
Arguments
| :: SDL_Folder |
|
| -> IO (PtrConst CChar) |
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 and getBasePath.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 getError.
- Returns
- either a null-terminated C string containing the full path to the folder, or NULL if an error happened.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetUserFolder. The safe flavor isgetUserFolderSafe. - C declaration
SDL_GetUserFolder, defined atSDL3/SDL_filesystem.h 236:42
Since: 3.2.0
Arguments
| :: SDL_Folder |
|
| -> IO (PtrConst CChar) |
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 and getBasePath.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 getError.
- Returns
- either a null-terminated C string containing the full path to the folder, or NULL if an error happened.
- Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetUserFolder. The unsafe flavor isgetUserFolder. - C declaration
SDL_GetUserFolder, defined atSDL3/SDL_filesystem.h 236:42
Since: 3.2.0
Create a directory, and any missing parent directories.
This reports success if path already exists as a directory.
If parent directories are missing, it will also create them. Note that if this fails, it will not remove any parent directories it already made.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_CreateDirectory. The safe flavor iscreateDirectorySafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_CreateDirectory, defined atSDL3/SDL_filesystem.h 304:34
Since: 3.2.0
Create a directory, and any missing parent directories.
This reports success if path already exists as a directory.
If parent directories are missing, it will also create them. Note that if this fails, it will not remove any parent directories it already made.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_CreateDirectory. The unsafe flavor iscreateDirectory. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_CreateDirectory, defined atSDL3/SDL_filesystem.h 304:34
Since: 3.2.0
enumerateDirectorySafe Source #
Arguments
| :: PtrConst CChar |
|
| -> SDL_EnumerateDirectoryCallback |
|
| -> Ptr Void |
|
| -> IO Bool |
Enumerate a directory through a callback function.
This function provides every directory entry through an app-provided callback, called once for each directory entry, until all results have been provided or the callback returns either SDL_ENUM_SUCCESS or SDL_ENUM_FAILURE.
This will return false if there was a system problem in general, or if a callback returns SDL_ENUM_FAILURE. A successful return means a callback returned SDL_ENUM_SUCCESS to halt enumeration, or all directory entries were enumerated.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_EnumerateDirectory. The unsafe import is not exported : invokes the callback per entry synchronously. If your callback is a non-Haskell function pointer that never re-enters the Haskell runtime, the unsafe import remains available asSDL3.Sys.Bindgen.Filesystem.Unsafe.sDL_EnumerateDirectory. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_EnumerateDirectory, defined atSDL3/SDL_filesystem.h 369:34
Since: 3.2.0
Remove a file or an empty directory.
Directories that are not empty will fail; this function will not recursely delete directory trees.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_RemovePath. The safe flavor isremovePathSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_RemovePath, defined atSDL3/SDL_filesystem.h 385:34
Since: 3.2.0
Remove a file or an empty directory.
Directories that are not empty will fail; this function will not recursely delete directory trees.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_RemovePath. The unsafe flavor isremovePath. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_RemovePath, defined atSDL3/SDL_filesystem.h 385:34
Since: 3.2.0
Rename a file or directory.
If the file at newpath already exists, it will be replaced.
Note that this will not copy files across filesystems/drives/volumes, as that is a much more complicated (and possibly time-consuming) operation.
Which is to say, if this function fails, to a temporary file in the same directory as copyFilenewpath, then from the temporary file to renamePathnewpath and on removePatholdpath might work for files. Renaming a non-empty directory across filesystems is dramatically more complex, however.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_RenamePath. The safe flavor isrenamePathSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_RenamePath, defined atSDL3/SDL_filesystem.h 410:34
Since: 3.2.0
Rename a file or directory.
If the file at newpath already exists, it will be replaced.
Note that this will not copy files across filesystems/drives/volumes, as that is a much more complicated (and possibly time-consuming) operation.
Which is to say, if this function fails, to a temporary file in the same directory as copyFilenewpath, then from the temporary file to renamePathnewpath and on removePatholdpath might work for files. Renaming a non-empty directory across filesystems is dramatically more complex, however.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_RenamePath. The unsafe flavor isrenamePath. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_RenamePath, defined atSDL3/SDL_filesystem.h 410:34
Since: 3.2.0
Copy a file.
If the file at newpath already exists, it will be overwritten with the contents of the file at oldpath.
This function will block until the copy is complete, which might be a significant time for large files on slow disks. On some platforms, the copy can be handed off to the OS itself, but on others SDL might just open both paths, and read from one and write to the other.
Note that this is not an atomic operation! If something tries to read from newpath while the copy is in progress, it will see an incomplete copy of the data, and if the calling thread terminates (or the power goes out) during the copy, newpath 's previous contents will be gone, replaced with an incomplete copy of the data. To avoid this risk, it is recommended that the app copy to a temporary file in the same directory as newpath, and if the copy is successful, use to replace renamePathnewpath with the temporary file. This will ensure that reads of newpath will either see a complete copy of the data, or it will see the pre-copy state of newpath.
This function attempts to synchronize the newly-copied data to disk before returning, if the platform allows it, so that the renaming trick will not have a problem in a system crash or power failure, where the file could be renamed but the contents never made it from the system file cache to the physical disk.
If the copy fails for any reason, the state of newpath is undefined. It might be half a copy, it might be the untouched data of what was already there, or it might be a zero-byte file, etc.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread, but this operation is not atomic, so the app might need to protect access to specific paths from other threads if appropriate.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_CopyFile. The safe flavor iscopyFileSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_CopyFile, defined atSDL3/SDL_filesystem.h 454:34
Since: 3.2.0
Copy a file.
If the file at newpath already exists, it will be overwritten with the contents of the file at oldpath.
This function will block until the copy is complete, which might be a significant time for large files on slow disks. On some platforms, the copy can be handed off to the OS itself, but on others SDL might just open both paths, and read from one and write to the other.
Note that this is not an atomic operation! If something tries to read from newpath while the copy is in progress, it will see an incomplete copy of the data, and if the calling thread terminates (or the power goes out) during the copy, newpath 's previous contents will be gone, replaced with an incomplete copy of the data. To avoid this risk, it is recommended that the app copy to a temporary file in the same directory as newpath, and if the copy is successful, use to replace renamePathnewpath with the temporary file. This will ensure that reads of newpath will either see a complete copy of the data, or it will see the pre-copy state of newpath.
This function attempts to synchronize the newly-copied data to disk before returning, if the platform allows it, so that the renaming trick will not have a problem in a system crash or power failure, where the file could be renamed but the contents never made it from the system file cache to the physical disk.
If the copy fails for any reason, the state of newpath is undefined. It might be half a copy, it might be the untouched data of what was already there, or it might be a zero-byte file, etc.
- Returns
- true on success or false on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread, but this operation is not atomic, so the app might need to protect access to specific paths from other threads if appropriate.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_CopyFile. The unsafe flavor iscopyFile. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_CopyFile, defined atSDL3/SDL_filesystem.h 454:34
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Ptr SDL_PathInfo |
|
| -> IO Bool |
Get information about a filesystem path.
Symlinks, on filesystems that support them, are always followed, so you will always get information on what the symlink eventually points to, and not the symlink itself.
- Returns
- true on success or false if the file doesn't exist, or another failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetPathInfo. The safe flavor isgetPathInfoSafe. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetPathInfo, defined atSDL3/SDL_filesystem.h 473:34
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> Ptr SDL_PathInfo |
|
| -> IO Bool |
Get information about a filesystem path.
Symlinks, on filesystems that support them, are always followed, so you will always get information on what the symlink eventually points to, and not the symlink itself.
- Returns
- true on success or false if the file doesn't exist, or another failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetPathInfo. The unsafe flavor isgetPathInfo. - Scalars
- The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
- C declaration
SDL_GetPathInfo, defined atSDL3/SDL_filesystem.h 473:34
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> SDL_GlobFlags |
|
| -> Ptr CInt |
|
| -> IO (Ptr (Ptr CChar)) |
Enumerate a directory tree, filtered by pattern, and return a list.
Files are filtered out if they don't match the string in pattern, which may contain wildcard characters * (match everything) and ? (match one character). If pattern is NULL, no filtering is done and all results are returned. Subdirectories are permitted, and are specified with a path separator of /. Wildcard characters * and ? never match a path separator.
flags may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching case-insensitive.
The returned array is always NULL-terminated, for your iterating convenience, but if count is non-NULL, on return it will contain the number of items in the array, not counting the NULL terminator.
- Returns
- an array of strings on success or NULL on failure; call
getErrorfor more information. This is a single allocation that should be freed withfreewhen it is no longer needed. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GlobDirectory. The safe flavor isglobDirectorySafe: blocks on directory traversal. - C declaration
SDL_GlobDirectory, defined atSDL3/SDL_filesystem.h 506:37
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> SDL_GlobFlags |
|
| -> Ptr CInt |
|
| -> IO (Ptr (Ptr CChar)) |
Enumerate a directory tree, filtered by pattern, and return a list.
Files are filtered out if they don't match the string in pattern, which may contain wildcard characters * (match everything) and ? (match one character). If pattern is NULL, no filtering is done and all results are returned. Subdirectories are permitted, and are specified with a path separator of /. Wildcard characters * and ? never match a path separator.
flags may be set to SDL_GLOB_CASEINSENSITIVE to make the pattern matching case-insensitive.
The returned array is always NULL-terminated, for your iterating convenience, but if count is non-NULL, on return it will contain the number of items in the array, not counting the NULL terminator.
- Returns
- an array of strings on success or NULL on failure; call
getErrorfor more information. This is a single allocation that should be freed withfreewhen it is no longer needed. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GlobDirectory. The unsafe flavor isglobDirectory: blocks on directory traversal. - C declaration
SDL_GlobDirectory, defined atSDL3/SDL_filesystem.h 506:37
Since: 3.2.0
getCurrentDirectory :: IO (Ptr CChar) Source #
Get what the system believes is the "current working directory."
For systems without a concept of a current working directory, this will still attempt to provide something reasonable.
SDL does not provide a means to change the current working directory; for platforms without this concept, this would cause surprises with file access outside of SDL.
The returned path is guaranteed to end with a path separator ('\' on Windows, '/' on most other platforms).
- Returns
- a UTF-8 string of the current working directory in platform-dependent notation. NULL if there's a problem. This should be freed with
freewhen it is no longer needed. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetCurrentDirectory. The safe flavor isgetCurrentDirectorySafe. - C declaration
SDL_GetCurrentDirectory, defined atSDL3/SDL_filesystem.h 529:36
Since: 3.2.0
getCurrentDirectorySafe :: IO (Ptr CChar) Source #
Get what the system believes is the "current working directory."
For systems without a concept of a current working directory, this will still attempt to provide something reasonable.
SDL does not provide a means to change the current working directory; for platforms without this concept, this would cause surprises with file access outside of SDL.
The returned path is guaranteed to end with a path separator ('\' on Windows, '/' on most other platforms).
- Returns
- a UTF-8 string of the current working directory in platform-dependent notation. NULL if there's a problem. This should be freed with
freewhen it is no longer needed. - Thread safety
- It is safe to call this function from any thread.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetCurrentDirectory. The unsafe flavor isgetCurrentDirectory. - C declaration
SDL_GetCurrentDirectory, defined atSDL3/SDL_filesystem.h 529:36
Since: 3.2.0