From 3bfada2e02d002b505788f249ca18f45d323d76a Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 10 Jan 2018 19:56:51 -0400 Subject: [PATCH] Android: resolve symlinks in SDL_AndroidGetInternalStoragePath (thanks Henrique Gemignani and cigumo!) Fixes issues on modern Android versions when the path is used in code that explicitly doesn't follow symlinks (such as PHYSFS_mkdir). --- src/core/android/SDL_android.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 614c1dfda..e907b7918 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -2029,10 +2029,14 @@ const char * SDL_AndroidGetInternalStoragePath(void) return NULL; } - /* path = fileObject.getAbsolutePath(); */ + /* path = fileObject.getCanonicalPath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), - "getAbsolutePath", "()Ljava/lang/String;"); + "getCanonicalPath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); + if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { + LocalReferenceHolder_Cleanup(&refs); + return NULL; + } path = (*env)->GetStringUTFChars(env, pathString, NULL); s_AndroidInternalFilesPath = SDL_strdup(path);