Fix Android TitleStorage: avoid leading '/' and handle NULL base path #13935
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On Android, assets are always packaged inside the assets/ folder of the APK.
There is no need to force a leading / in the path — on the contrary, having "/images/foo.png" makes AAssetManager fail, because it expects relative paths like "images/foo.png".
Previously:
Calling SDL_OpenTitleStorage("") built a base path of "/", producing lookups like "/images/..." that fail on Android.
Calling SDL_OpenTitleStorage(NULL, …) relied on SDL_GetBasePath(), but on Android this always returns NULL, so the call failed with “No available title storage driver”.
This patch fixes both issues by:
Treating override == "" as an empty base path (no leading /).
Falling back to an empty base path when SDL_GetBasePath() returns NULL on Android.
This allows both SDL_OpenTitleStorage("") and SDL_OpenTitleStorage(NULL, …) to work correctly on Android without any extra changes.
On other platforms, behavior remains unchanged.
Tested on macOS, Linux, Windows, and Android — everything works as expected.
Related issues: #13929, #13933