Gerhard Hoffmann
0ebf8b095a
reset result if necessary (for instance for showing current result in GUI.
38 lines
972 B
C++
38 lines
972 B
C++
#ifndef COMMAND_H_INCLUDED
|
|
#define COMMAND_H_INCLUDED
|
|
#endif // COMMAND_H_INCLUDED
|
|
|
|
#include <QObject>
|
|
#include <QCoreApplication>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QProcess>
|
|
#include <QMutex>
|
|
|
|
|
|
class Command : public QObject {
|
|
Q_OBJECT
|
|
|
|
QString m_command;
|
|
mutable QString m_commandResult;
|
|
int m_waitForStartTimeout;
|
|
int m_waitForFinishTimeout;
|
|
int m_exitCode;
|
|
mutable QMutex m_mtx;
|
|
public:
|
|
explicit Command(QString const &command,
|
|
int start_timeout = 100000,
|
|
int finish_timeout = 100000);
|
|
|
|
QString getCommandResult(bool reset = false) const;
|
|
QString command() const { return m_command; }
|
|
|
|
bool execute(QString workingDirectory, QStringList args = QStringList());
|
|
int exitCode() const { return m_exitCode; }
|
|
|
|
private slots:
|
|
void readyReadStandardOutput();
|
|
void readyReadStandardError();
|
|
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
|
};
|