/** * Return index of the archive type. Save to UString converted archive type name into 'formatNameString'. * @param env instance of JNIEnv * @param formatName archive type format name */ static int getIndexByName(JNIEnv * env, jstring formatName) { const jchar * formatNameJChars = env->GetStringChars(formatName, NULL); UString formatNameString; formatNameString = UnicodeHelper(formatNameJChars); env->ReleaseStringChars(formatName, formatNameJChars); TRACE("Format: " << formatNameString) return codecTools.codecs.FindFormatForArchiveType(formatNameString); }
STDMETHODIMP CPPToJavaArchiveOpenVolumeCallback::GetStream(const wchar_t *name, IInStream **inStream) { TRACE_OBJECT_CALL("GetStream"); JNIInstance jniInstance(_nativeMethodContext); JNIEnv * env = jniInstance.GetEnv(); if (inStream) { *inStream = NULL; } jstring nameString = env->NewString(UnicodeHelper(name), (jsize) wcslen( name)); jniInstance.PrepareCall(); jobject inStreamImpl = env->CallObjectMethod(_javaImplementation, _getStreamMethodID, nameString); if (jniInstance.IsExceptionOccurs()) { return S_FALSE; } if (inStream) { if (inStreamImpl) { CPPToJavaInStream * newInStream = new CPPToJavaInStream( _nativeMethodContext, env, inStreamImpl); lastVolume->AddInStream(newInStream); lastVolume = newInStream; CMyComPtr<IInStream> inStreamComPtr = newInStream; *inStream = inStreamComPtr.Detach(); } else { // jniInstance.ThrowSevenZipException( // "IArchiveOpenVolumeCallback.GetStream() returns stream=null. " // "Use non-zero return value if requested volume doesn't exists"); return S_FALSE; } } return S_OK; }
void userTrace(JNIEnvInstance & jniEnvInstance, jobject thiz, UString msg) { jstring jmsg = jniEnvInstance->NewString(UnicodeHelper(msg.GetBuffer(0)), msg.Length()); jni::OutArchiveImpl::traceMessage(jniEnvInstance, thiz, jmsg); jniEnvInstance.exceptionCheck(); // Ignore result jniEnvInstance->DeleteLocalRef(jmsg); }