Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "task.h"
- struct TaskResult
- {
- int exitCode ;
- QByteArray output ;
- }
- TaskResult runTask( const QString& exe )
- {
- return Task::await( [ exe ](){
- QProcess e ;
- e.start( exe ) ;
- e.waitForFinished( -1 ) ;
- TaskResult r ;
- r.exitCode = e.exitCode() ;
- r.output = r.readAllStandardOutput() ;
- return r ;
- } ) ;
- }
- QString ExtendedSysMon::getAllHdd()
- {
- if (debug) qDebug() << "[DE]" << "[getAllHdd]";
- QStringList devices;
- QString cmd = QString("find /dev -name [hms]d[a-z]");
- QString qoutput = QString("");
- if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Run cmd" << cmd;
- TaskResult r = runTask(cmd) ;
- if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Cmd returns" << r.exitCode;
- qoutput = QTextCodec::codecForMib(106)->toUnicode(r.readAllStandardOutput);
- for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++)
- devices.append(qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]);
- if (debug) qDebug() << "[DE]" << "[getAllHdd]" << ":" << "Device list" << devices;
- return devices.join(QChar(','));
- }
Advertisement
Add Comment
Please, Sign In to add comment