getFileVersion(): use only 16 byte of buffer filled by DC with version-info
of JSON-file.
This commit is contained in:
parent
f8472a3b87
commit
2e3af64c02
@ -592,10 +592,12 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
|||||||
|
|
||||||
QString Update::getFileVersion(QString const& jsonFileName) {
|
QString Update::getFileVersion(QString const& jsonFileName) {
|
||||||
// "version":"15.10.2023 14:55 02.00.06",
|
// "version":"15.10.2023 14:55 02.00.06",
|
||||||
static const QRegularExpression re("^.*(\\\"version\\\":)(.*)$");
|
static const QRegularExpression re("^.*(\\\"[Vv]ersion\\\":)([\\s\\\"]{0,})([^,\\\"]{0,}).*$");
|
||||||
|
|
||||||
QString fileVersion;
|
QString fileVersion("");
|
||||||
QFile inputFile(jsonFileName);
|
QFile inputFile(QDir::cleanPath(m_customerRepository + QDir::separator() + jsonFileName));
|
||||||
|
|
||||||
|
if (inputFile.exists()) {
|
||||||
if (inputFile.open(QIODevice::ReadOnly)) {
|
if (inputFile.open(QIODevice::ReadOnly)) {
|
||||||
QTextStream in(&inputFile);
|
QTextStream in(&inputFile);
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
@ -604,12 +606,18 @@ QString Update::getFileVersion(QString const& jsonFileName) {
|
|||||||
QRegularExpressionMatch match;
|
QRegularExpressionMatch match;
|
||||||
int idx = line.indexOf(re, 0, &match);
|
int idx = line.indexOf(re, 0, &match);
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
fileVersion = match.captured(match.lastCapturedIndex());
|
int const lastCaptured = match.lastCapturedIndex();
|
||||||
|
// the dc only sends 16 Byte
|
||||||
|
fileVersion = match.captured(lastCaptured);
|
||||||
|
fileVersion.truncate(16);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// qCritical() << "ERROR" << inputFile.fileName() << "does not exist";
|
||||||
|
}
|
||||||
|
|
||||||
return fileVersion;
|
return fileVersion;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user