From ee0a23c7ab8f7b936f2e0a9439cf89d197b01da0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Mar 2024 08:45:01 -0700 Subject: [PATCH] The storage ready callback is optional --- src/storage/SDL_storage.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/storage/SDL_storage.c b/src/storage/SDL_storage.c index 36671064dd..2f0f0d7c84 100644 --- a/src/storage/SDL_storage.c +++ b/src/storage/SDL_storage.c @@ -141,13 +141,8 @@ SDL_Storage *SDL_OpenStorage(const SDL_StorageInterface *iface, void *userdata) { SDL_Storage *storage; - if (iface->close == NULL || iface->ready == NULL || iface->fileSize == NULL) { - SDL_SetError("iface is missing required callbacks"); - return NULL; - } - - if ((iface->writeFile != NULL) != (iface->spaceRemaining != NULL)) { - SDL_SetError("Writeable containers must have both writeFile and spaceRemaining"); + if (!iface) { + SDL_InvalidParamError("iface"); return NULL; } @@ -177,7 +172,10 @@ SDL_bool SDL_StorageReady(SDL_Storage *storage) { CHECK_STORAGE_MAGIC_RET(SDL_FALSE) - return storage->iface.ready(storage->userdata); + if (storage->iface.ready) { + return storage->iface.ready(storage->userdata); + } + return SDL_TRUE; } int SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length)