Add utility isATBQTRunning().
This commit is contained in:
parent
ba71728979
commit
276d65a9d8
31
utils.cpp
31
utils.cpp
@ -7,6 +7,8 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
|
||||
int Utils::read1stLineOfFile(QString fileName) {
|
||||
QFile f(fileName);
|
||||
@ -193,3 +195,32 @@ QString Utils::getParentName() { // get name of parent process
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool Utils::isATBQTRunning() {
|
||||
QDirIterator it("/proc",
|
||||
QStringList() << "status",
|
||||
QDir::Files,
|
||||
QDirIterator::Subdirectories);
|
||||
while (it.hasNext()) {
|
||||
QString const &nextStatusFile = it.next();
|
||||
QFile f(nextStatusFile);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
// Name: ATBQT
|
||||
QStringList line = in.readLine().split(':');
|
||||
if (line.size() == 2) {
|
||||
if (line[0].trimmed() == "Name") {
|
||||
if (line[1].trimmed() == "ATBQT") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user