storage: enumerate and glob on storage can accept a NULL path.

This will be treated as the root of the storage tree.
This commit is contained in:
Ryan C. Gordon
2025-01-17 20:04:27 -05:00
parent a6a8598b98
commit 010f27dc70
2 changed files with 16 additions and 7 deletions

View File

@@ -284,8 +284,10 @@ bool SDL_EnumerateStorageDirectory(SDL_Storage *storage, const char *path, SDL_E
CHECK_STORAGE_MAGIC()
if (!path) {
return SDL_InvalidParamError("path");
} else if (!ValidateStoragePath(path)) {
path = ""; // we allow NULL to mean "root of the storage tree".
}
if (!ValidateStoragePath(path)) {
return false;
} else if (!storage->iface.enumerate) {
return SDL_Unsupported();
@@ -396,9 +398,10 @@ char **SDL_GlobStorageDirectory(SDL_Storage *storage, const char *path, const ch
CHECK_STORAGE_MAGIC_RET(NULL)
if (!path) {
SDL_InvalidParamError("path");
return NULL;
} else if (!ValidateStoragePath(path)) {
path = ""; // we allow NULL to mean "root of the storage tree".
}
if (!ValidateStoragePath(path)) {
return NULL;
}