@@ -98,6 +98,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_setGlobalParams(JNIEnv *env, jcl
9898JNIEXPORT jobject JNICALL
9999Java_at_tomtasche_reader_background_CoreWrapper_parseNative (JNIEnv *env, jclass clazz,
100100 jobject options) {
101+ std::error_code ec;
101102 auto logger = std::make_shared<AndroidLogger>();
102103
103104 jclass resultClass = env->FindClass (" at/tomtasche/reader/background/CoreWrapper$CoreResult" );
@@ -121,6 +122,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_parseNative(JNIEnv *env, jclass
121122 jboolean editable = env->GetBooleanField (options, editableField);
122123
123124 std::string outputPathCpp = getStringField (env, optionsClass, options, " outputPath" );
125+ std::string cachePathCpp = getStringField (env, optionsClass, options, " cachePath" );
124126
125127 jclass listClass = env->FindClass (" java/util/List" );
126128 jmethodID addMethod = env->GetMethodID (listClass, " add" , " (Ljava/lang/Object;)Z" );
@@ -195,11 +197,11 @@ Java_at_tomtasche_reader_background_CoreWrapper_parseNative(JNIEnv *env, jclass
195197
196198 __android_log_print (ANDROID_LOG_VERBOSE, " smn" , " Translate to HTML" );
197199
198- std::string output_tmp = outputPathCpp + " /tmp " ;
199- std::filesystem::create_directories (output_tmp );
200- odr::HtmlService service = odr::html::translate (file, output_tmp , htmlConfig, logger);
200+ std::filesystem::remove_all (cachePathCpp, ec) ;
201+ std::filesystem::create_directories (cachePathCpp );
202+ odr::HtmlService service = odr::html::translate (file, cachePathCpp , htmlConfig, logger);
201203 odr::Html html = service.bring_offline (outputPathCpp);
202- std::filesystem::remove_all (output_tmp );
204+ std::filesystem::remove_all (cachePathCpp );
203205
204206 for (const odr::HtmlPage &page: html.pages ()) {
205207 jstring pageName = env->NewStringUTF (page.name .c_str ());
@@ -318,6 +320,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFileNative(JNIEnv *env, jcla
318320 jobject options) {
319321 __android_log_print (ANDROID_LOG_INFO, " smn" , " host file" );
320322
323+ std::error_code ec;
321324 auto logger = std::make_shared<AndroidLogger>();
322325
323326 jclass resultClass = env->FindClass (" at/tomtasche/reader/background/CoreWrapper$CoreResult" );
@@ -350,6 +353,7 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFileNative(JNIEnv *env, jcla
350353 jboolean editable = env->GetBooleanField (options, editableField);
351354
352355 std::string outputPathCpp = getStringField (env, optionsClass, options, " outputPath" );
356+ std::string cachePathCpp = getStringField (env, optionsClass, options, " cachePath" );
353357
354358 jclass listClass = env->FindClass (" java/util/List" );
355359 jmethodID addMethod = env->GetMethodID (listClass, " add" , " (Ljava/lang/Object;)Z" );
@@ -395,9 +399,9 @@ Java_at_tomtasche_reader_background_CoreWrapper_hostFileNative(JNIEnv *env, jcla
395399 htmlConfig.text_document_margin = paging;
396400 htmlConfig.editable = editable;
397401
398- std::string output_tmp = outputPathCpp + " /tmp " ;
399- std::filesystem::create_directories (output_tmp );
400- odr::HtmlService service = odr::html::translate (file, output_tmp , htmlConfig, logger);
402+ std::filesystem::remove_all (cachePathCpp, ec) ;
403+ std::filesystem::create_directories (cachePathCpp );
404+ odr::HtmlService service = odr::html::translate (file, cachePathCpp , htmlConfig, logger);
401405 s_server->connect_service (service, prefixCpp);
402406 odr::HtmlViews htmlViews = service.list_views ();
403407
0 commit comments