diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-05 18:21:09 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-05 18:21:09 +0300 |
commit | 939a2d67ed75be714e9f3b1b918250d006b3860a (patch) | |
tree | c5700ba93652e26fc1f86235b1a278d90fd0ce91 /libraries/systeminfo/src/sys_unix.cpp | |
parent | 6f7d901a1f5c02e0629e4bae9172c04bb81ce0d9 (diff) | |
parent | ae793f6cf11658c9abc5111e82d5ba7b3e6af127 (diff) | |
download | PrismLauncher-939a2d67ed75be714e9f3b1b918250d006b3860a.tar.gz PrismLauncher-939a2d67ed75be714e9f3b1b918250d006b3860a.tar.bz2 PrismLauncher-939a2d67ed75be714e9f3b1b918250d006b3860a.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into develop12
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
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"; } } |