mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-20 10:28:23 +00:00
Added portable file and directory operations (thanks @icculus!)
This commit is contained in:
@@ -236,6 +236,102 @@ typedef enum
|
||||
*/
|
||||
extern DECLSPEC char *SDLCALL SDL_GetUserFolder(SDL_Folder folder);
|
||||
|
||||
|
||||
/* Abstract filesystem interface */
|
||||
|
||||
typedef enum SDL_PathType
|
||||
{
|
||||
SDL_PATHTYPE_FILE, /**< a normal file */
|
||||
SDL_PATHTYPE_DIRECTORY, /**< a directory */
|
||||
SDL_PATHTYPE_OTHER /**< something completely different like a device node (not a symlink, those are always followed) */
|
||||
} SDL_PathType;
|
||||
|
||||
/* SDL file timestamps are 64-bit integers representing seconds since the Unix epoch (Jan 1, 1970) */
|
||||
typedef Sint64 SDL_FileTimestamp;
|
||||
|
||||
typedef struct SDL_PathInfo
|
||||
{
|
||||
SDL_PathType type; /* the path type */
|
||||
Uint64 size; /* the file size in bytes */
|
||||
SDL_FileTimestamp create_time; /* the time when the path was created */
|
||||
SDL_FileTimestamp modify_time; /* the last time the path was modified */
|
||||
SDL_FileTimestamp access_time; /* the last time the path was read */
|
||||
} SDL_PathInfo;
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* \param path the path of the directory to create
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_CreateDirectory(const char *path);
|
||||
|
||||
/* Callback for filesystem enumeration. Return 1 to keep enumerating, 0 to stop enumerating (no error), -1 to stop enumerating and report an error. "origdir" is the directory being enumerated, "fname" is the enumerated entry. */
|
||||
typedef int (SDLCALL *SDL_EnumerateDirectoryCallback)(void *userdata, void *reserved, const char *origdir, const char *fname);
|
||||
|
||||
/**
|
||||
* Enumerate a directory.
|
||||
*
|
||||
* \param path the path of the directory to enumerate
|
||||
* \param callback a function that is called for each entry in the directory
|
||||
* \param userdata a pointer that is passed to `callback`
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata);
|
||||
|
||||
/**
|
||||
* Remove a file or an empty directory.
|
||||
*
|
||||
* \param path the path of the directory to enumerate
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RemovePath(const char *path);
|
||||
|
||||
/**
|
||||
* Rename a file or directory.
|
||||
*
|
||||
* \param oldpath the old path
|
||||
* \param newpath the new path
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_RenamePath(const char *oldpath, const char *newpath);
|
||||
|
||||
/**
|
||||
* Get information about a filesystem path.
|
||||
*
|
||||
* \param path the path to query
|
||||
* \param info a pointer filled in with information about the path
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetPathInfo(const char *path, SDL_PathInfo *info);
|
||||
|
||||
/* some helper functions ... */
|
||||
|
||||
/* Converts an SDL file timestamp into a Windows FILETIME (100-nanosecond intervals since January 1, 1601). Fills in the two 32-bit values of the FILETIME structure.
|
||||
*
|
||||
* \param ftime the time to convert
|
||||
* \param low a pointer filled in with the low portion of the Windows FILETIME value
|
||||
* \param high a pointer filled in with the high portion of the Windows FILETIME value
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FileTimeToWindows(Sint64 ftime, Uint32 *low, Uint32 *high);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -469,6 +469,11 @@
|
||||
#cmakedefine SDL_STORAGE_GENERIC @SDL_STORAGE_GENERIC@
|
||||
#cmakedefine SDL_STORAGE_STEAM @SDL_STORAGE_STEAM@
|
||||
|
||||
/* Enable system FSops support */
|
||||
#cmakedefine SDL_FSOPS_POSIX @SDL_FSOPS_POSIX@
|
||||
#cmakedefine SDL_FSOPS_WINDOWS @SDL_FSOPS_WINDOWS@
|
||||
#cmakedefine SDL_FSOPS_DUMMY @SDL_FSOPS_DUMMY@
|
||||
|
||||
/* Enable camera subsystem */
|
||||
#cmakedefine SDL_CAMERA_DRIVER_DUMMY @SDL_CAMERA_DRIVER_DUMMY@
|
||||
/* !!! FIXME: for later cmakedefine SDL_CAMERA_DRIVER_DISK @SDL_CAMERA_DRIVER_DISK@ */
|
||||
|
||||
@@ -187,6 +187,7 @@
|
||||
|
||||
/* Enable the filesystem driver */
|
||||
#define SDL_FILESYSTEM_ANDROID 1
|
||||
#define SDL_FSOPS_POSIX 1
|
||||
|
||||
/* Enable the camera driver */
|
||||
#define SDL_CAMERA_DRIVER_ANDROID 1
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
|
||||
/* Enable system filesystem support */
|
||||
#define SDL_FILESYSTEM_EMSCRIPTEN 1
|
||||
#define SDL_FSOPS_POSIX 1
|
||||
|
||||
/* Enable the camera driver */
|
||||
#define SDL_CAMERA_DRIVER_EMSCRIPTEN 1
|
||||
|
||||
@@ -207,6 +207,7 @@
|
||||
|
||||
/* enable filesystem support */
|
||||
#define SDL_FILESYSTEM_COCOA 1
|
||||
#define SDL_FSOPS_POSIX 1
|
||||
|
||||
/* enable camera support */
|
||||
#ifndef SDL_PLATFORM_TVOS
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
|
||||
/* enable filesystem support */
|
||||
#define SDL_FILESYSTEM_COCOA 1
|
||||
#define SDL_FSOPS_POSIX 1
|
||||
|
||||
/* enable camera support */
|
||||
#define SDL_CAMERA_DRIVER_COREMEDIA 1
|
||||
|
||||
@@ -88,6 +88,7 @@ typedef unsigned int uintptr_t;
|
||||
|
||||
/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
|
||||
#define SDL_FILESYSTEM_DUMMY 1
|
||||
#define SDL_FSOPS_DUMMY 1
|
||||
|
||||
/* Enable the camera driver (src/camera/dummy/\*.c) */
|
||||
#define SDL_CAMERA_DRIVER_DUMMY 1
|
||||
|
||||
@@ -85,6 +85,7 @@ typedef unsigned long uintptr_t;
|
||||
|
||||
/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
|
||||
#define SDL_FILESYSTEM_DUMMY 1
|
||||
#define SDL_FSOPS_DUMMY 1
|
||||
|
||||
/* Enable the camera driver (src/camera/dummy/\*.c) */
|
||||
#define SDL_CAMERA_DRIVER_DUMMY 1
|
||||
|
||||
@@ -312,6 +312,7 @@ typedef unsigned int uintptr_t;
|
||||
|
||||
/* Enable filesystem support */
|
||||
#define SDL_FILESYSTEM_WINDOWS 1
|
||||
#define SDL_FSOPS_WINDOWS 1
|
||||
|
||||
/* Enable the camera driver */
|
||||
#define SDL_CAMERA_DRIVER_MEDIAFOUNDATION 1
|
||||
|
||||
@@ -244,6 +244,7 @@
|
||||
|
||||
/* Enable filesystem support */
|
||||
#define SDL_FILESYSTEM_WINDOWS 1
|
||||
#define SDL_FSOPS_WINDOWS 1
|
||||
|
||||
/* Enable the camera driver (src/camera/dummy/\*.c) */ /* !!! FIXME */
|
||||
#define SDL_CAMERA_DRIVER_DUMMY 1
|
||||
|
||||
@@ -213,6 +213,10 @@
|
||||
/* Enable system power support */
|
||||
#define SDL_POWER_WINRT 1
|
||||
|
||||
/* Enable filesystem support */
|
||||
#define SDL_FILESYSTEM_WINDOWS 1
|
||||
#define SDL_FSOPS_WINDOWS 1
|
||||
|
||||
/* Enable the camera driver (src/camera/dummy/\*.c) */ /* !!! FIXME */
|
||||
#define SDL_CAMERA_DRIVER_DUMMY 1
|
||||
|
||||
|
||||
@@ -228,6 +228,8 @@
|
||||
/* Enable filesystem support */
|
||||
/* #define SDL_FILESYSTEM_WINDOWS 1*/
|
||||
#define SDL_FILESYSTEM_XBOX 1
|
||||
#define SDL_FSOPS_WINDOWS 1
|
||||
|
||||
|
||||
/* Disable IME as not supported yet (TODO: Xbox IME?) */
|
||||
#define SDL_DISABLE_WINDOWS_IME 1
|
||||
|
||||
Reference in New Issue
Block a user