예제 #1
0
JNIEXPORT jint JNICALL Java_csh_cryptonite_Cryptonite_jniExport(JNIEnv * env, jobject thiz, jobjectArray exportpaths,
                                                                jstring exportroot, jstring destdir)
{
    int res = checkGRoot();

    if (res != EXIT_SUCCESS) {
        return res;
    }

    int npaths = env->GetArrayLength(exportpaths);
    if (npaths==0)
        return res;
    
    // std::ostringstream info;
    // info << "Received " << npaths << " paths";
    // LOGI(info.str().c_str());

    jniStringManager mexportroot = jniStringManager(env, exportroot);
    
    jclass stringClass = env->FindClass("java/lang/String");
     
    std::set<std::string> std_exportpaths;
    for (int nstr = 0; nstr < npaths; ++nstr) {
        jobject obj = env->GetObjectArrayElement(exportpaths, nstr);
        if (env->IsInstanceOf(obj, stringClass)) {
            std_exportpaths.insert(jniStringManager(env, (jstring)obj).str());
        }
    }

    // std::set<std::string> allPaths(fullTree(std_exportpaths, mexportroot.str()));
    std::set<std::string> allPaths(std_exportpaths);
    
    // info.str("");
    // info << "Full size of tree is " << allPaths.size();
    // LOGI(info.str().c_str());

    
    std::set<std::string>::const_iterator it = allPaths.begin();
    // for (; it != allPaths.end(); ++it) {
    //     LOGI((*it).c_str());
    // }

    jniStringManager mdestdir(env, destdir);

    // if the dir doesn't exist, then create it (with user permission)
    if(!checkDir(mdestdir.str()) && !userAllowMkdir(mdestdir.c_str(), 0700))
	return EXIT_FAILURE;

    // LOGI((std::string("Exporting to ") + mdestdir.str()).c_str());
    res = (int)exportFiles(gRootInfo, "/", mdestdir.str(), allPaths);

    return res;
}
void
BatchExportDialog::okClicked()
{
    if (ok->text() == "Export") {
        aborted = false;

        overwrite->hide();
        status->setText("Exporting...");
        status->show();
        cancel->hide();
        ok->setText("Abort");
        exportFiles();
        status->setText(QString("%1 activities exported, %2 failed or skipped.").arg(exports).arg(fails));
        ok->setText("Finish");

    } else if (ok->text() == "Abort") {
        aborted = true;
    } else if (ok->text() == "Finish") {
        accept(); // our work is done!
    }
}
예제 #3
0
void
BatchExportDialog::okClicked()
{
    if (ok->text() == "Export" || ok->text() == tr("Export")) {
        aborted = false;

        overwrite->hide();
        status->setText(tr("Exporting..."));
        status->show();
        cancel->hide();
        ok->setText(tr("Abort"));
        appsettings->setValue(GC_BE_LASTDIR, dirName->text());
        appsettings->setValue(GC_BE_LASTFMT, format->currentIndex());
        exportFiles();
        status->setText(QString(tr("%1 rides exported, %2 failed or skipped.")).arg(exports).arg(fails));
        ok->setText(tr("Finish"));

    } else if (ok->text() == "Abort" || ok->text() == tr("Abort")) {
        aborted = true;
    } else if (ok->text() == "Finish" || ok->text() == tr("Finish")) {
        accept(); // our work is done!
    }
}