diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-14 18:16:53 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-14 18:16:53 +0200 |
commit | 91ba4cf75ee30c64779edb5b7644e5a830de5026 (patch) | |
tree | aa8c2433bfc3a54577aceeb706c4c2cd0986c95d /libraries/systeminfo/src/sys_unix.cpp | |
parent | 779f70057b021e285afd60cc650a14cd5feacffd (diff) | |
download | PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.tar.gz PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.tar.bz2 PrismLauncher-91ba4cf75ee30c64779edb5b7644e5a830de5026.zip |
chore: reformat
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'libraries/systeminfo/src/sys_unix.cpp')
-rw-r--r-- | libraries/systeminfo/src/sys_unix.cpp | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/libraries/systeminfo/src/sys_unix.cpp b/libraries/systeminfo/src/sys_unix.cpp index 3c63e73a..4e075959 100644 --- a/libraries/systeminfo/src/sys_unix.cpp +++ b/libraries/systeminfo/src/sys_unix.cpp @@ -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"; } } |