| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Storage
Contents
Description
The storage API is a high-level API designed to abstract away the portability issues that come up when using something lower-level (in SDL's case, this sits on top of the Filesystem and IOStream subsystems). It is significantly more restrictive than a typical filesystem API, for a number of reasons:
- What to Access: A common pitfall with existing filesystem APIs is the assumption that all storage is monolithic. However, many other platforms (game consoles in particular) are more strict about what type of filesystem is being accessed; for example, game content and user data are usually two separate storage devices with entirely different characteristics (and possibly different low-level APIs altogether!).
- How to Access: Another common mistake is applications assuming that all storage is universally writeable - again, many platforms treat game content and user data as two separate storage devices, and only user data is writeable while game content is read-only.
- When to Access: The most common portability issue with filesystem access is timing - you cannot always assume that the storage device is always accessible all of the time, nor can you assume that there are no limits to how long you have access to a particular device.
Consider the following example:
void ReadGameData(void)
{
extern char** fileNames;
extern size_t numFiles;
for (size_t i = 0; i < numFiles; i += 1) {
FILE *data = fopen(fileNames[i], "rwb");
if (data == NULL) {
// Something bad happened!
} else {
// A bunch of stuff happens here
fclose(data);
}
}
}
void ReadSave(void)
{
FILE *save = fopen("saves/save0.sav", "rb");
if (save == NULL) {
// Something bad happened!
} else {
// A bunch of stuff happens here
fclose(save);
}
}
void WriteSave(void)
{
FILE *save = fopen("saves/save0.sav", "wb");
if (save == NULL) {
// Something bad happened!
} else {
// A bunch of stuff happens here
fclose(save);
}
}
Going over the bullet points again:
- What to Access: This code accesses a global filesystem; game data and saves are all presumed to be in the current working directory (which may or may not be the game's installation folder!).
- How to Access: This code assumes that content paths are writeable, and that save data is also writeable despite being in the same location as the game data.
- When to Access: This code assumes that they can be called at any time, since the filesystem is always accessible and has no limits on how long the filesystem is being accessed.
Due to these assumptions, the filesystem code is not portable and will fail under these common scenarios:
- The game is installed on a device that is read-only, both content loading and game saves will fail or crash outright
- Game/User storage is not implicitly mounted, so no files will be found for either scenario when a platform requires explicitly mounting filesystems
- Save data may not be safe since the I/O is not being flushed or validated, so an error occurring elsewhere in the program may result in missing/corrupted save data
When using SDL_Storage, these types of problems are virtually impossible to trip over:
void ReadGameData(void)
{
extern char** fileNames;
extern size_t numFiles;
SDL_Storage *title = SDL_OpenTitleStorage(NULL, 0);
if (title == NULL) {
// Something bad happened!
}
while (!SDL_StorageReady(title)) {
SDL_Delay(1);
}
for (size_t i = 0; i < numFiles; i += 1) {
void* dst;
Uint64 dstLen = 0;
if (SDL_GetStorageFileSize(title, fileNames[i], &dstLen) && dstLen > 0) {
dst = SDL_malloc(dstLen);
if (SDL_ReadStorageFile(title, fileNames[i], dst, dstLen)) {
// A bunch of stuff happens here
} else {
// Something bad happened!
}
SDL_free(dst);
} else {
// Something bad happened!
}
}
SDL_CloseStorage(title);
}
void ReadSave(void)
{
SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0);
if (user == NULL) {
// Something bad happened!
}
while (!SDL_StorageReady(user)) {
SDL_Delay(1);
}
Uint64 saveLen = 0;
if (SDL_GetStorageFileSize(user, "save0.sav", &saveLen) && saveLen > 0) {
void* dst = SDL_malloc(saveLen);
if (SDL_ReadStorageFile(user, "save0.sav", dst, saveLen)) {
// A bunch of stuff happens here
} else {
// Something bad happened!
}
SDL_free(dst);
} else {
// Something bad happened!
}
SDL_CloseStorage(user);
}
void WriteSave(void)
{
SDL_Storage *user = SDL_OpenUserStorage("libsdl", "Storage Example", 0);
if (user == NULL) {
// Something bad happened!
}
while (!SDL_StorageReady(user)) {
SDL_Delay(1);
}
extern void *saveData; // A bunch of stuff happened here...
extern Uint64 saveLen;
if (!SDL_WriteStorageFile(user, "save0.sav", saveData, saveLen)) {
// Something bad happened!
}
SDL_CloseStorage(user);
}
Note the improvements that SDL_Storage makes:
- What to Access: This code explicitly reads from a title or user storage device based on the context of the function.
- How to Access: This code explicitly uses either a read or write function based on the context of the function.
- When to Access: This code explicitly opens the device when it needs to, and closes it when it is finished working with the filesystem.
The result is an application that is significantly more robust against the increasing demands of platforms and their filesystems!
A publicly available example of an SDL_Storage backend is the Steam Cloud backend - you can initialize Steamworks when starting the program, and then SDL will recognize that Steamworks is initialized and automatically use ISteamRemoteStorage when the application opens user storage. More importantly, when you open storage it knows to begin a "batch" of filesystem operations, and when you close storage it knows to end and flush the batch. This is used by Steam to support Dynamic Cloud Sync; users can save data on one PC, put the device to sleep, and then continue playing on another PC (and vice versa) with the save data fully synchronized across all devices, allowing for a seamless experience without having to do full restarts of the program.
Notes on valid paths
All paths in the Storage API use Unix-style path separators ('/'). Using a different path separator will not work, even if the underlying platform would otherwise accept it. This is to keep code using the Storage API portable between platforms and Storage implementations and simplify app code.
Paths with relative directories ("." and "..") are forbidden by the Storage API.
All valid UTF-8 strings (discounting the NULL terminator character and the '/' path separator) are usable for filenames, however, an underlying Storage implementation may not support particularly strange sequences and refuse to create files with those names, etc. Function interface for SDL_Storage.
Apps that want to supply a custom implementation of SDL_Storage will fill in all the functions in this struct, and then pass it to openStorage to create a custom SDL_Storage object.
It is not usually necessary to do this; SDL provides standard implementations for many things you might expect to do with an SDL_Storage.
This structure should be initialized using SDL_INIT_INTERFACE()
- See also
- SDL_INIT_INTERFACE
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.Storage.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.Storage
- openTitleStorage :: PtrConst CChar -> SDL_PropertiesID -> IO (Ptr SDL_Storage)
- openTitleStorageSafe :: PtrConst CChar -> SDL_PropertiesID -> IO (Ptr SDL_Storage)
- openUserStorage :: PtrConst CChar -> PtrConst CChar -> SDL_PropertiesID -> IO (Ptr SDL_Storage)
- openUserStorageSafe :: PtrConst CChar -> PtrConst CChar -> SDL_PropertiesID -> IO (Ptr SDL_Storage)
- openFileStorage :: PtrConst CChar -> IO (Ptr SDL_Storage)
- openFileStorageSafe :: PtrConst CChar -> IO (Ptr SDL_Storage)
- openStorage :: PtrConst SDL_StorageInterface -> Ptr Void -> IO (Ptr SDL_Storage)
- openStorageSafe :: PtrConst SDL_StorageInterface -> Ptr Void -> IO (Ptr SDL_Storage)
- closeStorage :: Ptr SDL_Storage -> IO Bool
- closeStorageSafe :: Ptr SDL_Storage -> IO Bool
- storageReady :: Ptr SDL_Storage -> IO Bool
- storageReadySafe :: Ptr SDL_Storage -> IO Bool
- getStorageFileSize :: Ptr SDL_Storage -> PtrConst CChar -> Ptr Uint64 -> IO Bool
- getStorageFileSizeSafe :: Ptr SDL_Storage -> PtrConst CChar -> Ptr Uint64 -> IO Bool
- readStorageFile :: Ptr SDL_Storage -> PtrConst CChar -> Ptr Void -> Word64 -> IO Bool
- readStorageFileSafe :: Ptr SDL_Storage -> PtrConst CChar -> Ptr Void -> Word64 -> IO Bool
- writeStorageFile :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst Void -> Word64 -> IO Bool
- writeStorageFileSafe :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst Void -> Word64 -> IO Bool
- createStorageDirectory :: Ptr SDL_Storage -> PtrConst CChar -> IO Bool
- createStorageDirectorySafe :: Ptr SDL_Storage -> PtrConst CChar -> IO Bool
- enumerateStorageDirectorySafe :: Ptr SDL_Storage -> PtrConst CChar -> SDL_EnumerateDirectoryCallback -> Ptr Void -> IO Bool
- removeStoragePath :: Ptr SDL_Storage -> PtrConst CChar -> IO Bool
- removeStoragePathSafe :: Ptr SDL_Storage -> PtrConst CChar -> IO Bool
- renameStoragePath :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst CChar -> IO Bool
- renameStoragePathSafe :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst CChar -> IO Bool
- copyStorageFile :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst CChar -> IO Bool
- copyStorageFileSafe :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst CChar -> IO Bool
- getStoragePathInfo :: Ptr SDL_Storage -> PtrConst CChar -> Ptr SDL_PathInfo -> IO Bool
- getStoragePathInfoSafe :: Ptr SDL_Storage -> PtrConst CChar -> Ptr SDL_PathInfo -> IO Bool
- getStorageSpaceRemaining :: Ptr SDL_Storage -> IO Word64
- getStorageSpaceRemainingSafe :: Ptr SDL_Storage -> IO Word64
- globStorageDirectory :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst CChar -> SDL_GlobFlags -> Ptr CInt -> IO (Ptr (Ptr CChar))
- globStorageDirectorySafe :: Ptr SDL_Storage -> PtrConst CChar -> PtrConst CChar -> SDL_GlobFlags -> Ptr CInt -> IO (Ptr (Ptr CChar))
Documentation
module SDL3.Sys.Bindgen.Storage
Function aliases
Arguments
| :: PtrConst CChar |
|
| -> SDL_PropertiesID |
|
| -> IO (Ptr SDL_Storage) |
Opens up a read-only container for the application's filesystem.
By default, openTitleStorage uses the generic storage implementation. When the path override is not provided, the generic implementation will use the output of getBasePath as the base path.
- Returns
- a title storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,openUserStorage,readStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_OpenTitleStorage. The safe flavor isopenTitleStorageSafe. - C declaration
SDL_OpenTitleStorage, defined atSDL3/SDL_storage.h 353:43
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> SDL_PropertiesID |
|
| -> IO (Ptr SDL_Storage) |
Opens up a read-only container for the application's filesystem.
By default, openTitleStorage uses the generic storage implementation. When the path override is not provided, the generic implementation will use the output of getBasePath as the base path.
- Returns
- a title storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,openUserStorage,readStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_OpenTitleStorage. The unsafe flavor isopenTitleStorage. - C declaration
SDL_OpenTitleStorage, defined atSDL3/SDL_storage.h 353:43
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> SDL_PropertiesID |
|
| -> IO (Ptr SDL_Storage) |
Opens up a container for a user's unique read/write filesystem.
While title storage can generally be kept open throughout runtime, user storage should only be opened when the client is ready to read/write files. This allows the backend to properly batch file operations and flush them when the container has been closed; ensuring safe and optimal save I/O.
- Returns
- a user storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,getStorageSpaceRemaining,openTitleStorage,readStorageFile,storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_OpenUserStorage. The safe flavor isopenUserStorageSafe. - C declaration
SDL_OpenUserStorage, defined atSDL3/SDL_storage.h 379:43
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> SDL_PropertiesID |
|
| -> IO (Ptr SDL_Storage) |
Opens up a container for a user's unique read/write filesystem.
While title storage can generally be kept open throughout runtime, user storage should only be opened when the client is ready to read/write files. This allows the backend to properly batch file operations and flush them when the container has been closed; ensuring safe and optimal save I/O.
- Returns
- a user storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,getStorageSpaceRemaining,openTitleStorage,readStorageFile,storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_OpenUserStorage. The unsafe flavor isopenUserStorage. - C declaration
SDL_OpenUserStorage, defined atSDL3/SDL_storage.h 379:43
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> IO (Ptr SDL_Storage) |
Opens up a container for local filesystem storage.
This is provided for development and tools. Portable applications should use for access to game data and openTitleStorage for access to user data.openUserStorage
- Returns
- a filesystem storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,getStorageSpaceRemaining,openTitleStorage,openUserStorage,readStorageFile,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_OpenFileStorage. The safe flavor isopenFileStorageSafe. - C declaration
SDL_OpenFileStorage, defined atSDL3/SDL_storage.h 403:43
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> IO (Ptr SDL_Storage) |
Opens up a container for local filesystem storage.
This is provided for development and tools. Portable applications should use for access to game data and openTitleStorage for access to user data.openUserStorage
- Returns
- a filesystem storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,getStorageSpaceRemaining,openTitleStorage,openUserStorage,readStorageFile,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_OpenFileStorage. The unsafe flavor isopenFileStorage. - C declaration
SDL_OpenFileStorage, defined atSDL3/SDL_storage.h 403:43
Since: 3.2.0
Arguments
| :: PtrConst SDL_StorageInterface |
|
| -> Ptr Void |
|
| -> IO (Ptr SDL_Storage) |
Opens up a container using a client-provided storage interface.
Applications do not need to use this function unless they are providing their own SDL_Storage implementation. If you just need an SDL_Storage, you should use the built-in implementations in SDL, like or openTitleStorage.openUserStorage
This function makes a copy of iface and the caller does not need to keep it around after this call.
- Returns
- a storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,getStorageSpaceRemaining, SDL_INIT_INTERFACE,readStorageFile,storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_OpenStorage. The safe flavor isopenStorageSafe. - C declaration
SDL_OpenStorage, defined atSDL3/SDL_storage.h 432:43
Since: 3.2.0
Arguments
| :: PtrConst SDL_StorageInterface |
|
| -> Ptr Void |
|
| -> IO (Ptr SDL_Storage) |
Opens up a container using a client-provided storage interface.
Applications do not need to use this function unless they are providing their own SDL_Storage implementation. If you just need an SDL_Storage, you should use the built-in implementations in SDL, like or openTitleStorage.openUserStorage
This function makes a copy of iface and the caller does not need to keep it around after this call.
- Returns
- a storage container on success or NULL on failure; call
getErrorfor more information. - See also
closeStorage,getStorageFileSize,getStorageSpaceRemaining, SDL_INIT_INTERFACE,readStorageFile,storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_OpenStorage. The unsafe flavor isopenStorage. - C declaration
SDL_OpenStorage, defined atSDL3/SDL_storage.h 432:43
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> IO Bool |
Closes and frees a storage container.
- Returns
- true if the container was freed with no errors, false otherwise; call
getErrorfor more information. Even if the function returns an error, the container data will be freed; the error is only for informational purposes. - See also
openFileStorage,openStorage,openTitleStorage,openUserStorage
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_CloseStorage. The safe flavor iscloseStorageSafe. - 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_CloseStorage, defined atSDL3/SDL_storage.h 450:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> IO Bool |
Closes and frees a storage container.
- Returns
- true if the container was freed with no errors, false otherwise; call
getErrorfor more information. Even if the function returns an error, the container data will be freed; the error is only for informational purposes. - See also
openFileStorage,openStorage,openTitleStorage,openUserStorage
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_CloseStorage. The unsafe flavor iscloseStorage. - 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_CloseStorage, defined atSDL3/SDL_storage.h 450:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> IO Bool |
Checks if the storage container is ready to use.
This function should be called in regular intervals until it returns true - however, it is not recommended to spinwait on this call, as the backend may depend on a synchronous message loop. You might instead poll this in your game's main loop while processing events and drawing a loading screen.
- Returns
- true if the container is ready, false otherwise.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_StorageReady. The safe flavor isstorageReadySafe. - 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_StorageReady, defined atSDL3/SDL_storage.h 465:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> IO Bool |
Checks if the storage container is ready to use.
This function should be called in regular intervals until it returns true - however, it is not recommended to spinwait on this call, as the backend may depend on a synchronous message loop. You might instead poll this in your game's main loop while processing events and drawing a loading screen.
- Returns
- true if the container is ready, false otherwise.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_StorageReady. The unsafe flavor isstorageReady. - 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_StorageReady, defined atSDL3/SDL_storage.h 465:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> Ptr Uint64 |
|
| -> IO Bool |
Query the size of a file within a storage container.
- Returns
- true if the file could be queried or false on failure; call
getErrorfor more information. - See also
readStorageFile,storageReady
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetStorageFileSize. The safe flavor isgetStorageFileSizeSafe. - 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_GetStorageFileSize, defined atSDL3/SDL_storage.h 481:34
Since: 3.2.0
getStorageFileSizeSafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> Ptr Uint64 |
|
| -> IO Bool |
Query the size of a file within a storage container.
- Returns
- true if the file could be queried or false on failure; call
getErrorfor more information. - See also
readStorageFile,storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetStorageFileSize. The unsafe flavor isgetStorageFileSize. - 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_GetStorageFileSize, defined atSDL3/SDL_storage.h 481:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> Ptr Void |
|
| -> Word64 |
|
| -> IO Bool |
Synchronously read a file from a storage container into a client-provided buffer.
The value of length must match the length of the file exactly; call to get this value. This behavior may be relaxed in a future release.getStorageFileSize
- Returns
- true if the file was read or false on failure; call
getErrorfor more information. - See also
getStorageFileSize,storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_ReadStorageFile. The safe flavor isreadStorageFileSafe: dispatches through the storage's SDL_StorageInterface, which may be implemented in Haskell. - 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_ReadStorageFile, defined atSDL3/SDL_storage.h 504:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> Ptr Void |
|
| -> Word64 |
|
| -> IO Bool |
Synchronously read a file from a storage container into a client-provided buffer.
The value of length must match the length of the file exactly; call to get this value. This behavior may be relaxed in a future release.getStorageFileSize
- Returns
- true if the file was read or false on failure; call
getErrorfor more information. - See also
getStorageFileSize,storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_ReadStorageFile. The unsafe flavor isreadStorageFile: dispatches through the storage's SDL_StorageInterface, which may be implemented in Haskell. - 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_ReadStorageFile, defined atSDL3/SDL_storage.h 504:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> PtrConst Void |
|
| -> Word64 |
|
| -> IO Bool |
Synchronously write a file from client memory into a storage container.
- Returns
- true if the file was written or false on failure; call
getErrorfor more information. - See also
getStorageSpaceRemaining,readStorageFile,storageReady
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_WriteStorageFile. The safe flavor iswriteStorageFileSafe: dispatches through the storage's SDL_StorageInterface, which may be implemented in Haskell. - 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_WriteStorageFile, defined atSDL3/SDL_storage.h 522:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> PtrConst Void |
|
| -> Word64 |
|
| -> IO Bool |
Synchronously write a file from client memory into a storage container.
- Returns
- true if the file was written or false on failure; call
getErrorfor more information. - See also
getStorageSpaceRemaining,readStorageFile,storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_WriteStorageFile. The unsafe flavor iswriteStorageFile: dispatches through the storage's SDL_StorageInterface, which may be implemented in Haskell. - 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_WriteStorageFile, defined atSDL3/SDL_storage.h 522:34
Since: 3.2.0
createStorageDirectory Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Create a directory in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_CreateStorageDirectory. The safe flavor iscreateStorageDirectorySafe. - 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_CreateStorageDirectory, defined atSDL3/SDL_storage.h 536:34
Since: 3.2.0
createStorageDirectorySafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Create a directory in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_CreateStorageDirectory. The unsafe flavor iscreateStorageDirectory. - 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_CreateStorageDirectory, defined atSDL3/SDL_storage.h 536:34
Since: 3.2.0
enumerateStorageDirectorySafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> SDL_EnumerateDirectoryCallback |
|
| -> Ptr Void |
|
| -> IO Bool |
Enumerate a directory in a storage container 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.
If path is NULL, this is treated as a request to enumerate the root of the storage container's tree. An empty string also works for this.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_EnumerateStorageDirectory. 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.Storage.Unsafe.sDL_EnumerateStorageDirectory. - 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_EnumerateStorageDirectory, defined atSDL3/SDL_storage.h 565:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Remove a file or an empty directory in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_RemoveStoragePath. The safe flavor isremoveStoragePathSafe. - 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_RemoveStoragePath, defined atSDL3/SDL_storage.h 579:34
Since: 3.2.0
removeStoragePathSafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Remove a file or an empty directory in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_RemoveStoragePath. The unsafe flavor isremoveStoragePath. - 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_RemoveStoragePath, defined atSDL3/SDL_storage.h 579:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Rename a file or directory in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_RenameStoragePath. The safe flavor isrenameStoragePathSafe. - 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_RenameStoragePath, defined atSDL3/SDL_storage.h 594:34
Since: 3.2.0
renameStoragePathSafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Rename a file or directory in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_RenameStoragePath. The unsafe flavor isrenameStoragePath. - 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_RenameStoragePath, defined atSDL3/SDL_storage.h 594:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Copy a file in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_CopyStorageFile. The safe flavor iscopyStorageFileSafe. - 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_CopyStorageFile, defined atSDL3/SDL_storage.h 609:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> PtrConst CChar |
|
| -> IO Bool |
Copy a file in a writable storage container.
- Returns
- true on success or false on failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_CopyStorageFile. The unsafe flavor iscopyStorageFile. - 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_CopyStorageFile, defined atSDL3/SDL_storage.h 609:34
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> Ptr SDL_PathInfo |
|
| -> IO Bool |
Get information about a filesystem path in a storage container.
- Returns
- true on success or false if the file doesn't exist, or another failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetStoragePathInfo. The safe flavor isgetStoragePathInfoSafe. - 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_GetStoragePathInfo, defined atSDL3/SDL_storage.h 625:34
Since: 3.2.0
getStoragePathInfoSafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> PtrConst CChar |
|
| -> Ptr SDL_PathInfo |
|
| -> IO Bool |
Get information about a filesystem path in a storage container.
- Returns
- true on success or false if the file doesn't exist, or another failure; call
getErrorfor more information. - See also
storageReady
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetStoragePathInfo. The unsafe flavor isgetStoragePathInfo. - 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_GetStoragePathInfo, defined atSDL3/SDL_storage.h 625:34
Since: 3.2.0
getStorageSpaceRemaining Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> IO Word64 |
Queries the remaining space in a storage container.
- Returns
- the amount of remaining space, in bytes.
- See also
storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GetStorageSpaceRemaining. The safe flavor isgetStorageSpaceRemainingSafe. - 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_GetStorageSpaceRemaining, defined atSDL3/SDL_storage.h 638:36
Since: 3.2.0
getStorageSpaceRemainingSafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> IO Word64 |
Queries the remaining space in a storage container.
- Returns
- the amount of remaining space, in bytes.
- See also
storageReady,writeStorageFile
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GetStorageSpaceRemaining. The unsafe flavor isgetStorageSpaceRemaining. - 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_GetStorageSpaceRemaining, defined atSDL3/SDL_storage.h 638:36
Since: 3.2.0
Arguments
| :: Ptr SDL_Storage |
|
| -> 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.
If path is NULL, this is treated as a request to enumerate the root of the storage container's tree. An empty string also works for this.
- Returns
- an array of strings on success or NULL on failure; call
getErrorfor more information. The caller should pass the returned pointer tofreewhen done with it. 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, assuming the
storageobject is thread-safe.
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_GlobStorageDirectory. The safe flavor isglobStorageDirectorySafe: dispatches through the storage's SDL_StorageInterface, which may be implemented in Haskell. - C declaration
SDL_GlobStorageDirectory, defined atSDL3/SDL_storage.h 678:37
Since: 3.2.0
globStorageDirectorySafe Source #
Arguments
| :: Ptr SDL_Storage |
|
| -> 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.
If path is NULL, this is treated as a request to enumerate the root of the storage container's tree. An empty string also works for this.
- Returns
- an array of strings on success or NULL on failure; call
getErrorfor more information. The caller should pass the returned pointer tofreewhen done with it. 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, assuming the
storageobject is thread-safe.
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_GlobStorageDirectory. The unsafe flavor isglobStorageDirectory: dispatches through the storage's SDL_StorageInterface, which may be implemented in Haskell. - C declaration
SDL_GlobStorageDirectory, defined atSDL3/SDL_storage.h 678:37
Since: 3.2.0