| 1464 | } |
| 1465 | |
| 1466 | bool android_DumpPathExtra(Vector<Platform::FileInfo>& fileVector) |
| 1467 | { |
| 1468 | // Attaches the current thread to the JVM. |
| 1469 | jint lResult; |
| 1470 | jint lFlags = 0; |
| 1471 | JavaVM* lJavaVM = engine.app->activity->vm; |
| 1472 | JNIEnv* lJNIEnv = engine.app->activity->env; |
| 1473 | |
| 1474 | JavaVMAttachArgs lJavaVMAttachArgs; |
| 1475 | lJavaVMAttachArgs.version = JNI_VERSION_1_6; |
| 1476 | lJavaVMAttachArgs.name = "NativeThread"; |
| 1477 | lJavaVMAttachArgs.group = NULL; |
| 1478 | |
| 1479 | lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs); |
| 1480 | if (lResult == JNI_ERR) { |
| 1481 | return false; |
| 1482 | } |
| 1483 | |
| 1484 | // Retrieves NativeActivity. |
| 1485 | jobject lNativeActivity = engine.app->activity->clazz; |
| 1486 | jclass ClassNativeActivity = lJNIEnv->GetObjectClass(lNativeActivity); |
| 1487 | |
| 1488 | jmethodID getClassLoader = lJNIEnv->GetMethodID(ClassNativeActivity,"getClassLoader", "()Ljava/lang/ClassLoader;"); |
| 1489 | jobject cls = lJNIEnv->CallObjectMethod(lNativeActivity, getClassLoader); |
| 1490 | jclass classLoader = lJNIEnv->FindClass("java/lang/ClassLoader"); |
| 1491 | jmethodID findClass = lJNIEnv->GetMethodID(classLoader, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;"); |
| 1492 | jstring strClassName = lJNIEnv->NewStringUTF("com.garagegames.torque2d.FileWalker"); |
| 1493 | jclass FileWalkerClass = (jclass)lJNIEnv->CallObjectMethod(cls, findClass, strClassName); |
| 1494 | jmethodID MethodExtraPaths = lJNIEnv->GetStaticMethodID(FileWalkerClass, "getRestOfDump", "()[Ljava/lang/String;"); |
| 1495 | jobjectArray stringArray = (jobjectArray)lJNIEnv->CallStaticObjectMethod(FileWalkerClass, MethodExtraPaths); |
| 1496 | |
| 1497 | bool ret = true; |
| 1498 | if (stringArray) |
| 1499 | { |
| 1500 | int stringCount = lJNIEnv->GetArrayLength(stringArray); |
| 1501 | |
| 1502 | if (stringCount < 500) |
| 1503 | ret = false; |
| 1504 | |
| 1505 | for (int i=0; i<stringCount; i++) { |
| 1506 | jstring string = (jstring) lJNIEnv->GetObjectArrayElement(stringArray, i); |
| 1507 | const char *rawString = lJNIEnv->GetStringUTFChars(string, 0); |
| 1508 | std::string str = rawString; |
| 1509 | lJNIEnv->ReleaseStringUTFChars(string, rawString); |
| 1510 | |
| 1511 | const U32 fileSize = Platform::getFileSize(str.c_str()); |
| 1512 | fileVector.increment(); |
| 1513 | Platform::FileInfo& rInfo = fileVector.last(); |
| 1514 | std::string fileName = std::string( |
| 1515 | std::find_if( str.rbegin(), str.rend(), |
| 1516 | MatchPathSeparator() ).base(), |
| 1517 | str.end() ); |
| 1518 | rInfo.pFullPath = StringTable->insert(str.substr(0,str.find(fileName)-1).c_str()); |
| 1519 | rInfo.pFileName = StringTable->insert(fileName.c_str()); |
| 1520 | rInfo.fileSize = fileSize; |
| 1521 | |
| 1522 | dumpPathBackup.increment(); |
| 1523 | Platform::FileInfo& rInfo2 = dumpPathBackup.last(); |
no test coverage detected