Merge commit '3a7f96fd99528968c39b5be81db067ca018d432b' into dev
This commit is contained in:
31
external/SDL/src/storage/SDL_storage.c
vendored
31
external/SDL/src/storage/SDL_storage.c
vendored
@@ -153,6 +153,11 @@ SDL_Storage *SDL_OpenStorage(const SDL_StorageInterface *iface, void *userdata)
|
||||
SDL_InvalidParamError("iface");
|
||||
return NULL;
|
||||
}
|
||||
if (iface->version < sizeof(*iface)) {
|
||||
// Update this to handle older versions of this interface
|
||||
SDL_SetError("Invalid interface, should be initialized with SDL_INIT_INTERFACE()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
storage = (SDL_Storage *)SDL_calloc(1, sizeof(*storage));
|
||||
if (storage) {
|
||||
@@ -162,7 +167,7 @@ SDL_Storage *SDL_OpenStorage(const SDL_StorageInterface *iface, void *userdata)
|
||||
return storage;
|
||||
}
|
||||
|
||||
SDL_bool SDL_CloseStorage(SDL_Storage *storage)
|
||||
bool SDL_CloseStorage(SDL_Storage *storage)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
@@ -175,7 +180,7 @@ SDL_bool SDL_CloseStorage(SDL_Storage *storage)
|
||||
return result;
|
||||
}
|
||||
|
||||
SDL_bool SDL_StorageReady(SDL_Storage *storage)
|
||||
bool SDL_StorageReady(SDL_Storage *storage)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC_RET(false)
|
||||
|
||||
@@ -185,7 +190,7 @@ SDL_bool SDL_StorageReady(SDL_Storage *storage)
|
||||
return true;
|
||||
}
|
||||
|
||||
SDL_bool SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length)
|
||||
bool SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length)
|
||||
{
|
||||
SDL_PathInfo info;
|
||||
|
||||
@@ -202,7 +207,7 @@ SDL_bool SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *destination, Uint64 length)
|
||||
bool SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *destination, Uint64 length)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
@@ -217,7 +222,7 @@ SDL_bool SDL_ReadStorageFile(SDL_Storage *storage, const char *path, void *desti
|
||||
return storage->iface.read_file(storage->userdata, path, destination, length);
|
||||
}
|
||||
|
||||
SDL_bool SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void *source, Uint64 length)
|
||||
bool SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void *source, Uint64 length)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
@@ -232,7 +237,7 @@ SDL_bool SDL_WriteStorageFile(SDL_Storage *storage, const char *path, const void
|
||||
return storage->iface.write_file(storage->userdata, path, source, length);
|
||||
}
|
||||
|
||||
SDL_bool SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path)
|
||||
bool SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
@@ -247,7 +252,7 @@ SDL_bool SDL_CreateStorageDirectory(SDL_Storage *storage, const char *path)
|
||||
return storage->iface.mkdir(storage->userdata, path);
|
||||
}
|
||||
|
||||
SDL_bool SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata)
|
||||
bool SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
@@ -262,7 +267,7 @@ SDL_bool SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, S
|
||||
return storage->iface.enumerate(storage->userdata, path, callback, userdata);
|
||||
}
|
||||
|
||||
SDL_bool SDL_RemoveStoragePath(SDL_Storage *storage, const char *path)
|
||||
bool SDL_RemoveStoragePath(SDL_Storage *storage, const char *path)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
@@ -277,7 +282,7 @@ SDL_bool SDL_RemoveStoragePath(SDL_Storage *storage, const char *path)
|
||||
return storage->iface.remove(storage->userdata, path);
|
||||
}
|
||||
|
||||
SDL_bool SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const char *newpath)
|
||||
bool SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const char *newpath)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
@@ -295,7 +300,7 @@ SDL_bool SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const
|
||||
return storage->iface.rename(storage->userdata, oldpath, newpath);
|
||||
}
|
||||
|
||||
SDL_bool SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath)
|
||||
bool SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
@@ -313,7 +318,7 @@ SDL_bool SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const ch
|
||||
return storage->iface.copy(storage->userdata, oldpath, newpath);
|
||||
}
|
||||
|
||||
SDL_bool SDL_GetStoragePathInfo(SDL_Storage *storage, const char *path, SDL_PathInfo *info)
|
||||
bool SDL_GetStoragePathInfo(SDL_Storage *storage, const char *path, SDL_PathInfo *info)
|
||||
{
|
||||
SDL_PathInfo dummy;
|
||||
|
||||
@@ -347,12 +352,12 @@ Uint64 SDL_GetStorageSpaceRemaining(SDL_Storage *storage)
|
||||
return storage->iface.space_remaining(storage->userdata);
|
||||
}
|
||||
|
||||
static SDL_bool GlobStorageDirectoryGetPathInfo(const char *path, SDL_PathInfo *info, void *userdata)
|
||||
static bool GlobStorageDirectoryGetPathInfo(const char *path, SDL_PathInfo *info, void *userdata)
|
||||
{
|
||||
return SDL_GetStoragePathInfo((SDL_Storage *) userdata, path, info);
|
||||
}
|
||||
|
||||
static SDL_bool GlobStorageDirectoryEnumerator(const char *path, SDL_EnumerateDirectoryCallback cb, void *cbuserdata, void *userdata)
|
||||
static bool GlobStorageDirectoryEnumerator(const char *path, SDL_EnumerateDirectoryCallback cb, void *cbuserdata, void *userdata)
|
||||
{
|
||||
return SDL_EnumerateStorageDirectory((SDL_Storage *) userdata, path, cb, cbuserdata);
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ static char *GENERIC_INTERNAL_CreateFullPath(const char *base, const char *relat
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_CloseStorage(void *userdata)
|
||||
static bool GENERIC_CloseStorage(void *userdata)
|
||||
{
|
||||
SDL_free(userdata);
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_EnumerateStorageDirectory(void *userdata, const char *path, SDL_EnumerateDirectoryCallback callback, void *callback_userdata)
|
||||
static bool GENERIC_EnumerateStorageDirectory(void *userdata, const char *path, SDL_EnumerateDirectoryCallback callback, void *callback_userdata)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -57,7 +57,7 @@ static SDL_bool GENERIC_EnumerateStorageDirectory(void *userdata, const char *pa
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_GetStoragePathInfo(void *userdata, const char *path, SDL_PathInfo *info)
|
||||
static bool GENERIC_GetStoragePathInfo(void *userdata, const char *path, SDL_PathInfo *info)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -70,7 +70,7 @@ static SDL_bool GENERIC_GetStoragePathInfo(void *userdata, const char *path, SDL
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_ReadStorageFile(void *userdata, const char *path, void *destination, Uint64 length)
|
||||
static bool GENERIC_ReadStorageFile(void *userdata, const char *path, void *destination, Uint64 length)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -93,7 +93,7 @@ static SDL_bool GENERIC_ReadStorageFile(void *userdata, const char *path, void *
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
||||
static bool GENERIC_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
||||
{
|
||||
// TODO: Recursively create subdirectories with SDL_CreateDirectory
|
||||
bool result = false;
|
||||
@@ -118,7 +118,7 @@ static SDL_bool GENERIC_WriteStorageFile(void *userdata, const char *path, const
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_CreateStorageDirectory(void *userdata, const char *path)
|
||||
static bool GENERIC_CreateStorageDirectory(void *userdata, const char *path)
|
||||
{
|
||||
// TODO: Recursively create subdirectories with SDL_CreateDirectory
|
||||
bool result = false;
|
||||
@@ -132,7 +132,7 @@ static SDL_bool GENERIC_CreateStorageDirectory(void *userdata, const char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_RemoveStoragePath(void *userdata, const char *path)
|
||||
static bool GENERIC_RemoveStoragePath(void *userdata, const char *path)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -145,7 +145,7 @@ static SDL_bool GENERIC_RemoveStoragePath(void *userdata, const char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_RenameStoragePath(void *userdata, const char *oldpath, const char *newpath)
|
||||
static bool GENERIC_RenameStoragePath(void *userdata, const char *oldpath, const char *newpath)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -160,7 +160,7 @@ static SDL_bool GENERIC_RenameStoragePath(void *userdata, const char *oldpath, c
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool GENERIC_CopyStorageFile(void *userdata, const char *oldpath, const char *newpath)
|
||||
static bool GENERIC_CopyStorageFile(void *userdata, const char *oldpath, const char *newpath)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -182,6 +182,7 @@ static Uint64 GENERIC_GetStorageSpaceRemaining(void *userdata)
|
||||
}
|
||||
|
||||
static const SDL_StorageInterface GENERIC_title_iface = {
|
||||
sizeof(SDL_StorageInterface),
|
||||
GENERIC_CloseStorage,
|
||||
NULL, // ready
|
||||
GENERIC_EnumerateStorageDirectory,
|
||||
@@ -224,6 +225,7 @@ TitleStorageBootStrap GENERIC_titlebootstrap = {
|
||||
};
|
||||
|
||||
static const SDL_StorageInterface GENERIC_user_iface = {
|
||||
sizeof(SDL_StorageInterface),
|
||||
GENERIC_CloseStorage,
|
||||
NULL, // ready
|
||||
GENERIC_EnumerateStorageDirectory,
|
||||
@@ -259,6 +261,7 @@ UserStorageBootStrap GENERIC_userbootstrap = {
|
||||
};
|
||||
|
||||
static const SDL_StorageInterface GENERIC_file_iface = {
|
||||
sizeof(SDL_StorageInterface),
|
||||
GENERIC_CloseStorage,
|
||||
NULL, // ready
|
||||
GENERIC_EnumerateStorageDirectory,
|
||||
|
||||
@@ -38,7 +38,7 @@ typedef struct STEAM_RemoteStorage
|
||||
#include "SDL_steamstorage_proc.h"
|
||||
} STEAM_RemoteStorage;
|
||||
|
||||
static SDL_bool STEAM_CloseStorage(void *userdata)
|
||||
static bool STEAM_CloseStorage(void *userdata)
|
||||
{
|
||||
bool result = true;
|
||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
||||
@@ -53,12 +53,12 @@ static SDL_bool STEAM_CloseStorage(void *userdata)
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool STEAM_StorageReady(void *userdata)
|
||||
static bool STEAM_StorageReady(void *userdata)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_bool STEAM_GetStoragePathInfo(void *userdata, const char *path, SDL_PathInfo *info)
|
||||
static bool STEAM_GetStoragePathInfo(void *userdata, const char *path, SDL_PathInfo *info)
|
||||
{
|
||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
||||
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
||||
@@ -74,7 +74,7 @@ static SDL_bool STEAM_GetStoragePathInfo(void *userdata, const char *path, SDL_P
|
||||
return true;
|
||||
}
|
||||
|
||||
static SDL_bool STEAM_ReadStorageFile(void *userdata, const char *path, void *destination, Uint64 length)
|
||||
static bool STEAM_ReadStorageFile(void *userdata, const char *path, void *destination, Uint64 length)
|
||||
{
|
||||
bool result = false;
|
||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
||||
@@ -93,7 +93,7 @@ static SDL_bool STEAM_ReadStorageFile(void *userdata, const char *path, void *de
|
||||
return result;
|
||||
}
|
||||
|
||||
static SDL_bool STEAM_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
||||
static bool STEAM_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
||||
{
|
||||
int result = false;
|
||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
||||
@@ -129,6 +129,7 @@ static Uint64 STEAM_GetStorageSpaceRemaining(void *userdata)
|
||||
}
|
||||
|
||||
static const SDL_StorageInterface STEAM_user_iface = {
|
||||
sizeof(SDL_StorageInterface),
|
||||
STEAM_CloseStorage,
|
||||
STEAM_StorageReady,
|
||||
NULL, // enumerate
|
||||
|
||||
Reference in New Issue
Block a user