| 2624 | } |
| 2625 | |
| 2626 | void T2DActivity::loadInternalDir(){ |
| 2627 | |
| 2628 | // Attaches the current thread to the JVM. |
| 2629 | jint lResult; |
| 2630 | jint lFlags = 0; |
| 2631 | JavaVM* lJavaVM = platState.engine->app->activity->vm; |
| 2632 | JNIEnv* lJNIEnv = platState.engine->app->activity->env; |
| 2633 | |
| 2634 | JavaVMAttachArgs lJavaVMAttachArgs; |
| 2635 | lJavaVMAttachArgs.version = JNI_VERSION_1_6; |
| 2636 | lJavaVMAttachArgs.name = "NativeThread"; |
| 2637 | lJavaVMAttachArgs.group = NULL; |
| 2638 | |
| 2639 | lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs); |
| 2640 | if (lResult == JNI_ERR) { |
| 2641 | return; |
| 2642 | } |
| 2643 | |
| 2644 | // Retrieves NativeActivity. |
| 2645 | jobject lNativeActivity = platState.engine->app->activity->clazz; |
| 2646 | jclass ClassNativeActivity = lJNIEnv->GetObjectClass(lNativeActivity); |
| 2647 | |
| 2648 | jmethodID getFilesDir = lJNIEnv->GetMethodID(ClassNativeActivity, "getFilesDir", "()Ljava/io/File;"); |
| 2649 | jobject file = lJNIEnv->CallObjectMethod(platState.engine->app->activity->clazz, getFilesDir); |
| 2650 | jclass fileClass = lJNIEnv->FindClass("java/io/File"); |
| 2651 | jmethodID getAbsolutePath = lJNIEnv->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;"); |
| 2652 | jstring jpath = (jstring)lJNIEnv->CallObjectMethod(file, getAbsolutePath); |
| 2653 | const char* app_dir = lJNIEnv->GetStringUTFChars(jpath, NULL); |
| 2654 | |
| 2655 | strcpy(internalDir, app_dir); |
| 2656 | internalDir[strlen(app_dir)] = '\0'; |
| 2657 | |
| 2658 | lJNIEnv->ReleaseStringUTFChars(jpath, app_dir); |
| 2659 | |
| 2660 | // Finished with the JVM. |
| 2661 | lJavaVM->DetachCurrentThread(); |
| 2662 | } |
| 2663 | |
| 2664 | |
| 2665 | char* _AndroidLoadInternalFile(const char* fn, U32 *size) |