当前位置: 首页>>代码示例>>C++>>正文


C++ QProcess::setStandardInputFile方法代码示例

本文整理汇总了C++中QProcess::setStandardInputFile方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::setStandardInputFile方法的具体用法?C++ QProcess::setStandardInputFile怎么用?C++ QProcess::setStandardInputFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QProcess的用法示例。


在下文中一共展示了QProcess::setStandardInputFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: performPatchApplication

static inline bool performPatchApplication(const QString &patch, const QString &workingDirectory,
                                           bool reverse = false)
{
    QProcess process;
    process.setProgram(PATCH);
    process.setWorkingDirectory(workingDirectory);
    process.setStandardInputFile(patch);
    QStringList arguments;
    arguments << P1_FLAG << DRY_RUN_FLAG;
    if (!reverse) {
        arguments << T_FLAG << N_FLAG;
    } else {
        arguments << F_FLAG << R_FLAG;
    }
    process.setArguments(arguments);
    process.start();
    process.waitForFinished(-1);
    if (process.exitCode() != 0) {
        return false;
    }

    arguments.clear();
    arguments << P1_FLAG;
    if (!reverse) {
        arguments << T_FLAG << N_FLAG;
    } else {
        arguments << F_FLAG << R_FLAG;
    }
    process.setArguments(arguments);
    process.start();
    process.waitForFinished(-1);
    return (process.exitCode() == 0);
}
开发者ID:MFaroTusino,项目名称:patchmanager,代码行数:33,代码来源:patchmanagerobject.cpp

示例2: runApp

static Result runApp(const QString &execPath, const QString &execParam, const QString &execPipeIn = "")
{
//   QString outPipePath = FS::TmpFilePath("pipeOut");

    QProcess app;
    app.setStandardInputFile(execPipeIn);
//    app.setStandardOutputFile(outPipePath);
//    app.setStandardErrorFile(outPipePath);
    app.start("\"" + execPath + "\"" + " " + execParam);
    if (!app.waitForStarted()) {
        qWarning() << "Cmd Exec Failed:" << app.errorString();
        return Result(Result::Failed, app.errorString(), "", app.program());
    }

    if (!app.waitForFinished(-1)) {
        qWarning() << "waitForFinished Failed:" << app.errorString();
        return Result(Result::Failed, app.errorString(), "", app.program());
    }

    auto standardError = app.readAllStandardError();

    if (QProcess::NormalExit != app.exitStatus()) {
        qWarning() << "exitStatus error:" << app.exitStatus() << standardError << app.program();
        return Result(Result::Failed, standardError, "", app.program());
    }

    if (0 != app.exitCode()) {
        qWarning() << "exitCode error:" << app.exitCode() << standardError << app.program();
        return Result(Result::Failed, standardError, "", app.program());
    }

    Result rest(Result::Success, standardError, app.readAllStandardOutput());
    return rest;
}
开发者ID:linuxdeepin,项目名称:deepin-boot-maker,代码行数:34,代码来源:Cmd.cpp

示例3: startQProcess

void SyncProcess::startQProcess(QProcess& process)
{
    const QString command = generateFullCommand();
    if (command.isEmpty())
        throw SyncProcessException("Cannot start process '" + generateDescription() + "'. The full command is '" + command + "'.");

    if (!mStdInFile.isEmpty())
        process.setStandardInputFile(mStdInFile);

    process.setProcessEnvironment(generateFullEnvironment());
    mDiagnosticInfo += QObject::tr("Starting process '%1'\n").arg(generateDescription());
    process.setWorkingDirectory(mWorkingDirectory);
    process.start(command, generateFullArguments());
    process.waitForStarted();

    if (process.state() != QProcess::Running)
        throw SyncProcessException("Starting process '" + generateDescription() + "' failed. The process is not in a running state.");
}
开发者ID:alexander-manley,项目名称:scap-workbench,代码行数:18,代码来源:ProcessHelpers.cpp

示例4: RunApp

static QString RunApp(const QString &execPath, const QString &execParam, const QString &execPipeIn="") {
    QString outPipePath = Xapi::TmpFilePath("pipeOut");

    QProcess app;
    app.setStandardInputFile(execPipeIn);
    app.setStandardOutputFile(outPipePath);
    app.setStandardErrorFile(outPipePath);
    app.start(execPath + " " + execParam);
    app.waitForFinished();

    if (QProcess::NormalExit != app.exitStatus())
        qDebug()<<app.error()<<app.errorString()<<app.state();

    QFile locale(outPipePath);
    if (!locale.open(QIODevice::ReadOnly)) {
        qDebug()<<"Open output pipe Fialed!"<<outPipePath;
        return "";
    }
    QTextStream localets(&locale);

    QString outUtf8PipePath = Xapi::TmpFilePath("utf8pipeOut");
    QFile utf8(outUtf8PipePath);
    if (!utf8.open(QIODevice::WriteOnly)) {
        qDebug()<<"Open utf8 output pipe Fialed!"<<outUtf8PipePath;
        return "";
    }
    QTextStream utf8ts(&utf8);
    utf8ts.setCodec("utf8");
    utf8ts<<localets.readAll();
    locale.close();
    utf8.close();

    utf8.open(QIODevice::ReadOnly);
    QString ret = QString(utf8.readAll());
    utf8.close();

    locale.remove();
    utf8.remove();
    return ret;
}
开发者ID:Abuchidefan,项目名称:deepin-windows-installer,代码行数:40,代码来源:xsys.cpp

示例5: setStandardInputFile

void QProcessProto::setStandardInputFile(const QString &fileName)
{
  QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
  if (item)
    item->setStandardInputFile(fileName);
}
开发者ID:,项目名称:,代码行数:6,代码来源:


注:本文中的QProcess::setStandardInputFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。