@@ -6,9 +6,9 @@
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
|
||||
Sys::KernelInfo Sys::getKernelInfo()
|
||||
{
|
||||
@@ -27,18 +27,16 @@ Sys::KernelInfo Sys::getKernelInfo()
|
||||
out.kernelMinor = 0;
|
||||
out.kernelPatch = 0;
|
||||
auto sections = release.split('-');
|
||||
if(sections.size() >= 1) {
|
||||
if (sections.size() >= 1) {
|
||||
auto versionParts = sections[0].split('.');
|
||||
if(versionParts.size() >= 3) {
|
||||
if (versionParts.size() >= 3) {
|
||||
out.kernelMajor = versionParts[0].toInt();
|
||||
out.kernelMinor = versionParts[1].toInt();
|
||||
out.kernelPatch = versionParts[2].toInt();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
qWarning() << "Not enough version numbers in " << sections[0] << " found " << versionParts.size();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
qWarning() << "Not enough '-' sections in " << release << " found " << sections.size();
|
||||
}
|
||||
return out;
|
||||
@@ -49,17 +47,12 @@ uint64_t Sys::getSystemRam()
|
||||
std::string token;
|
||||
#ifdef Q_OS_LINUX
|
||||
std::ifstream file("/proc/meminfo");
|
||||
while(file >> token)
|
||||
{
|
||||
if(token == "MemTotal:")
|
||||
{
|
||||
while (file >> token) {
|
||||
if (token == "MemTotal:") {
|
||||
uint64_t mem;
|
||||
if(file >> mem)
|
||||
{
|
||||
if (file >> mem) {
|
||||
return mem * 1024ull;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -68,18 +61,16 @@ uint64_t Sys::getSystemRam()
|
||||
}
|
||||
#elif defined(Q_OS_FREEBSD)
|
||||
char buff[512];
|
||||
FILE *fp = popen("sysctl hw.physmem", "r");
|
||||
if (fp != NULL)
|
||||
{
|
||||
while(fgets(buff, 512, fp) != NULL)
|
||||
{
|
||||
std::string str(buff);
|
||||
uint64_t mem = std::stoull(str.substr(12, std::string::npos));
|
||||
return mem * 1024ull;
|
||||
}
|
||||
FILE* fp = popen("sysctl hw.physmem", "r");
|
||||
if (fp != NULL) {
|
||||
while (fgets(buff, 512, fp) != NULL) {
|
||||
std::string str(buff);
|
||||
uint64_t mem = std::stoull(str.substr(12, std::string::npos));
|
||||
return mem * 1024ull;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0; // nothing found
|
||||
return 0; // nothing found
|
||||
}
|
||||
|
||||
Sys::DistributionInfo Sys::getDistributionInfo()
|
||||
@@ -88,18 +79,13 @@ Sys::DistributionInfo Sys::getDistributionInfo()
|
||||
DistributionInfo lsb_info = read_lsb_release();
|
||||
DistributionInfo legacy_info = read_legacy_release();
|
||||
DistributionInfo result = systemd_info + lsb_info + legacy_info;
|
||||
if(result.distributionName.isNull())
|
||||
{
|
||||
if (result.distributionName.isNull()) {
|
||||
result.distributionName = "unknown";
|
||||
}
|
||||
if(result.distributionVersion.isNull())
|
||||
{
|
||||
if(result.distributionName == "arch")
|
||||
{
|
||||
if (result.distributionVersion.isNull()) {
|
||||
if (result.distributionName == "arch") {
|
||||
result.distributionVersion = "rolling";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result.distributionVersion = "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user