mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
The storage ready callback is optional
This commit is contained in:
@@ -141,13 +141,8 @@ SDL_Storage *SDL_OpenStorage(const SDL_StorageInterface *iface, void *userdata)
|
|||||||
{
|
{
|
||||||
SDL_Storage *storage;
|
SDL_Storage *storage;
|
||||||
|
|
||||||
if (iface->close == NULL || iface->ready == NULL || iface->fileSize == NULL) {
|
if (!iface) {
|
||||||
SDL_SetError("iface is missing required callbacks");
|
SDL_InvalidParamError("iface");
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((iface->writeFile != NULL) != (iface->spaceRemaining != NULL)) {
|
|
||||||
SDL_SetError("Writeable containers must have both writeFile and spaceRemaining");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +172,10 @@ SDL_bool SDL_StorageReady(SDL_Storage *storage)
|
|||||||
{
|
{
|
||||||
CHECK_STORAGE_MAGIC_RET(SDL_FALSE)
|
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)
|
int SDL_GetStorageFileSize(SDL_Storage *storage, const char *path, Uint64 *length)
|
||||||
|
Reference in New Issue
Block a user