本文整理汇总了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);
}
示例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;
}
示例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.");
}
示例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;
}
示例5: setStandardInputFile
void QProcessProto::setStandardInputFile(const QString &fileName)
{
QProcess *item = qscriptvalue_cast<QProcess*>(thisObject());
if (item)
item->setStandardInputFile(fileName);
}