|
@@ -47,6 +47,13 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
|
|
|
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_IOS)
|
|
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_IOS)
|
|
|
if (*path != '/') {
|
|
if (*path != '/') {
|
|
|
#ifdef SDL_PLATFORM_ANDROID
|
|
#ifdef SDL_PLATFORM_ANDROID
|
|
|
|
|
+ if (SDL_strncmp(path, "assets://", 9) == 0) {
|
|
|
|
|
+ char *pathwithsep = NULL;
|
|
|
|
|
+ SDL_asprintf(&pathwithsep, "%s%s", path, (path[SDL_strlen(path) - 1] != '/') ? "/" : "");
|
|
|
|
|
+ const bool retval = pathwithsep ? Android_JNI_EnumerateAssetDirectory(pathwithsep, cb, userdata) : false;
|
|
|
|
|
+ SDL_free(pathwithsep);
|
|
|
|
|
+ return retval;
|
|
|
|
|
+ }
|
|
|
SDL_asprintf(&apath, "%s/%s", SDL_GetAndroidInternalStoragePath(), path);
|
|
SDL_asprintf(&apath, "%s/%s", SDL_GetAndroidInternalStoragePath(), path);
|
|
|
#elif defined(SDL_PLATFORM_IOS)
|
|
#elif defined(SDL_PLATFORM_IOS)
|
|
|
char *base = SDL_GetPrefPath("", "");
|
|
char *base = SDL_GetPrefPath("", "");
|
|
@@ -89,14 +96,13 @@ bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback
|
|
|
|
|
|
|
|
DIR *dir = opendir(pathwithsep);
|
|
DIR *dir = opendir(pathwithsep);
|
|
|
if (!dir) {
|
|
if (!dir) {
|
|
|
-#ifdef SDL_PLATFORM_ANDROID // Maybe it's an asset...?
|
|
|
|
|
|
|
+#ifdef SDL_PLATFORM_ANDROID // Maybe it's an asset... that didn't use an "assets://" URL?
|
|
|
const bool retval = Android_JNI_EnumerateAssetDirectory(pathwithsep + extralen, cb, userdata);
|
|
const bool retval = Android_JNI_EnumerateAssetDirectory(pathwithsep + extralen, cb, userdata);
|
|
|
SDL_free(pathwithsep);
|
|
SDL_free(pathwithsep);
|
|
|
return retval;
|
|
return retval;
|
|
|
-#else
|
|
|
|
|
|
|
+#endif
|
|
|
SDL_free(pathwithsep);
|
|
SDL_free(pathwithsep);
|
|
|
return SDL_SetError("Can't open directory: %s", strerror(errno));
|
|
return SDL_SetError("Can't open directory: %s", strerror(errno));
|
|
|
-#endif
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SDL_EnumerationResult result = SDL_ENUM_CONTINUE;
|
|
SDL_EnumerationResult result = SDL_ENUM_CONTINUE;
|
|
@@ -342,6 +348,8 @@ bool SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info)
|
|
|
#ifdef SDL_PLATFORM_ANDROID
|
|
#ifdef SDL_PLATFORM_ANDROID
|
|
|
if (*path == '/') {
|
|
if (*path == '/') {
|
|
|
rc = stat(path, &statbuf);
|
|
rc = stat(path, &statbuf);
|
|
|
|
|
+ } else if (SDL_strncmp(path, "assets://", 9) == 0) {
|
|
|
|
|
+ return Android_JNI_GetAssetPathInfo(path, info);
|
|
|
} else {
|
|
} else {
|
|
|
char *apath = NULL;
|
|
char *apath = NULL;
|
|
|
SDL_asprintf(&apath, "%s/%s", SDL_GetAndroidInternalStoragePath(), path);
|
|
SDL_asprintf(&apath, "%s/%s", SDL_GetAndroidInternalStoragePath(), path);
|
|
@@ -351,7 +359,7 @@ bool SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info)
|
|
|
rc = stat(apath, &statbuf);
|
|
rc = stat(apath, &statbuf);
|
|
|
SDL_free(apath);
|
|
SDL_free(apath);
|
|
|
}
|
|
}
|
|
|
- if (rc < 0) {
|
|
|
|
|
|
|
+ if (rc < 0) { // Maybe it's an asset... that didn't use an "assets://" URL?
|
|
|
return Android_JNI_GetAssetPathInfo(path, info);
|
|
return Android_JNI_GetAssetPathInfo(path, info);
|
|
|
}
|
|
}
|
|
|
#elif defined(SDL_PLATFORM_IOS)
|
|
#elif defined(SDL_PLATFORM_IOS)
|