Android: resolve symlinks in SDL_AndroidGetInternalStoragePath (thanks Henrique Gemignani and cigumo!)
authorAlex Szpakowski <slime73@gmail.com>
Wed, 10 Jan 2018 19:56:51 -0400
changeset 1182356d562cbea17
parent 11822 3f32b61fd611
child 11824 00fb5966c44f
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
     1.1 --- a/src/core/android/SDL_android.c	Wed Jan 10 10:42:40 2018 -0800
     1.2 +++ b/src/core/android/SDL_android.c	Wed Jan 10 19:56:51 2018 -0400
     1.3 @@ -2029,10 +2029,14 @@
     1.4              return NULL;
     1.5          }
     1.6  
     1.7 -        /* path = fileObject.getAbsolutePath(); */
     1.8 +        /* path = fileObject.getCanonicalPath(); */
     1.9          mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject),
    1.10 -                "getAbsolutePath", "()Ljava/lang/String;");
    1.11 +                "getCanonicalPath", "()Ljava/lang/String;");
    1.12          pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid);
    1.13 +        if (Android_JNI_ExceptionOccurred(SDL_FALSE)) {
    1.14 +            LocalReferenceHolder_Cleanup(&refs);
    1.15 +            return NULL;
    1.16 +        }
    1.17  
    1.18          path = (*env)->GetStringUTFChars(env, pathString, NULL);
    1.19          s_AndroidInternalFilesPath = SDL_strdup(path);