mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-14 09:57:31 -04:00
Put more code in try{}
This commit is contained in:
parent
2474008e16
commit
c1845e7bc2
15
kiwix.c
15
kiwix.c
@ -160,7 +160,6 @@ JNIEXPORT jbyteArray JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getContent(JNIE
|
|||||||
setStringObjValue("", mimeTypeObj, env);
|
setStringObjValue("", mimeTypeObj, env);
|
||||||
setIntObjValue(0, sizeObj, env);
|
setIntObjValue(0, sizeObj, env);
|
||||||
jbyteArray data = env->NewByteArray(0);
|
jbyteArray data = env->NewByteArray(0);
|
||||||
bool isOK = false;
|
|
||||||
|
|
||||||
/* Retrieve the content */
|
/* Retrieve the content */
|
||||||
if (reader != NULL) {
|
if (reader != NULL) {
|
||||||
@ -171,19 +170,17 @@ JNIEXPORT jbyteArray JNICALL Java_org_kiwix_kiwixmobile_JNIKiwix_getContent(JNIE
|
|||||||
|
|
||||||
pthread_mutex_lock(&readerLock);
|
pthread_mutex_lock(&readerLock);
|
||||||
try {
|
try {
|
||||||
isOK = reader->getContentByUrl(cUrl, cData, cSize, cMimeType);
|
if (reader->getContentByUrl(cUrl, cData, cSize, cMimeType)) {
|
||||||
} catch (exception &e) {
|
|
||||||
LOGI(e.what());
|
|
||||||
std::cerr << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&readerLock);
|
|
||||||
|
|
||||||
if (isOK) {
|
|
||||||
data = env->NewByteArray(cSize);
|
data = env->NewByteArray(cSize);
|
||||||
env->SetByteArrayRegion(data, 0, cSize, reinterpret_cast<const jbyte*>(cData.c_str()));
|
env->SetByteArrayRegion(data, 0, cSize, reinterpret_cast<const jbyte*>(cData.c_str()));
|
||||||
setStringObjValue(cMimeType, mimeTypeObj, env);
|
setStringObjValue(cMimeType, mimeTypeObj, env);
|
||||||
setIntObjValue(cSize, sizeObj, env);
|
setIntObjValue(cSize, sizeObj, env);
|
||||||
}
|
}
|
||||||
|
} catch (exception &e) {
|
||||||
|
LOGI(e.what());
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&readerLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user