@@ -47,6 +47,13 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
4747#if defined(SDL_PLATFORM_ANDROID ) || defined(SDL_PLATFORM_IOS )
4848 if (* path != '/' ) {
4949 #ifdef SDL_PLATFORM_ANDROID
50+ if (SDL_strncmp (path , "asset://" , 8 ) == 0 ) {
51+ char * pathwithsep = NULL ;
52+ SDL_asprintf (& pathwithsep , "%s%s" , path , (path [SDL_strlen (path ) - 1 ] != '/' ) ? "/" : "" );
53+ const bool retval = pathwithsep ? Android_JNI_EnumerateAssetDirectory (pathwithsep , cb , userdata ) : false;
54+ SDL_free (pathwithsep );
55+ return retval ;
56+ }
5057 SDL_asprintf (& apath , "%s/%s" , SDL_GetAndroidInternalStoragePath (), path );
5158 #elif defined(SDL_PLATFORM_IOS )
5259 char * base = SDL_GetPrefPath ("" , "" );
@@ -89,14 +96,15 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
8996
9097 DIR * dir = opendir (pathwithsep );
9198 if (!dir ) {
92- #ifdef SDL_PLATFORM_ANDROID // Maybe it's an asset...?
93- const bool retval = Android_JNI_EnumerateAssetDirectory (pathwithsep + extralen , cb , userdata );
94- SDL_free (pathwithsep );
95- return retval ;
96- #else
99+ #ifdef SDL_PLATFORM_ANDROID // Maybe it's an asset... that didn't use an "asset://" URL?
100+ if (SDL_GetHintBoolean (SDL_HINT_ANDROID_ALLOW_ASSET_DIR_FALLBACK , true)) {
101+ const bool retval = Android_JNI_EnumerateAssetDirectory (pathwithsep + extralen , cb , userdata );
102+ SDL_free (pathwithsep );
103+ return retval ;
104+ }
105+ #endif
97106 SDL_free (pathwithsep );
98107 return SDL_SetError ("Can't open directory: %s" , strerror (errno ));
99- #endif
100108 }
101109
102110 SDL_EnumerationResult result = SDL_ENUM_CONTINUE ;
@@ -342,6 +350,8 @@ bool SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info)
342350#ifdef SDL_PLATFORM_ANDROID
343351 if (* path == '/' ) {
344352 rc = stat (path , & statbuf );
353+ } else if (SDL_strncmp (path , "asset://" , 8 ) == 0 ) {
354+ return Android_JNI_GetAssetPathInfo (path , info );
345355 } else {
346356 char * apath = NULL ;
347357 SDL_asprintf (& apath , "%s/%s" , SDL_GetAndroidInternalStoragePath (), path );
@@ -351,7 +361,7 @@ bool SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info)
351361 rc = stat (apath , & statbuf );
352362 SDL_free (apath );
353363 }
354- if (rc < 0 ) {
364+ if (( rc < 0 ) && SDL_GetHintBoolean ( SDL_HINT_ANDROID_ALLOW_ASSET_DIR_FALLBACK , true) ) {
355365 return Android_JNI_GetAssetPathInfo (path , info );
356366 }
357367#elif defined(SDL_PLATFORM_IOS )
0 commit comments