checkin for saving current state
This commit is contained in:
55
common/src/utils_internal.cpp
Normal file
55
common/src/utils_internal.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
|
||||
namespace internal {
|
||||
|
||||
int read1stLineOfFile(QString fileName) {
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
return in.readLine().toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString customerRepoRoot() {
|
||||
return "/opt/app/tools/atbupdate/";
|
||||
}
|
||||
|
||||
QString customerRepoDirName() {
|
||||
int const customerNr = read1stLineOfFile("/mnt/system_data/cust_nr");
|
||||
return (customerNr != -1) ? QString("customer_%1").arg(customerNr) : "";
|
||||
}
|
||||
|
||||
QString customerRepoDir() {
|
||||
QString const &n = customerRepoDirName();
|
||||
QString const &r = customerRepoRoot();
|
||||
return !n.isEmpty() ? QDir::cleanPath(r + QDir::separator() + n) : "";
|
||||
}
|
||||
|
||||
bool customerRepoExists() {
|
||||
QString const repoDir{customerRepoDir()};
|
||||
return !repoDir.isEmpty() ? QDir(repoDir).exists() : false;
|
||||
}
|
||||
|
||||
QString repositoryUrl() {
|
||||
return "gitea@ptu-config.atb-comm.de:ATB/";
|
||||
}
|
||||
|
||||
QString branchName() {
|
||||
int const zoneNr = read1stLineOfFile("/mnt/system_data/zone_nr");
|
||||
if (zoneNr != -1) {
|
||||
return QString("zg1/zone%1").arg(zoneNr);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
} // namespace internal
|
Reference in New Issue
Block a user