diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-11-22 00:57:15 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-11-22 02:46:18 +0100 |
commit | 44805145dc385ba9ffe0d78f2e723cef42984537 (patch) | |
tree | ffbb3b8f08258e4627d008ae2b3e1c99860a81b6 /libraries/ganalytics/src/sys_unix.cpp | |
parent | 00c4aebeaafe08d6834c90b097c5018493ee62ec (diff) | |
download | PrismLauncher-44805145dc385ba9ffe0d78f2e723cef42984537.tar.gz PrismLauncher-44805145dc385ba9ffe0d78f2e723cef42984537.tar.bz2 PrismLauncher-44805145dc385ba9ffe0d78f2e723cef42984537.zip |
NOISSUE add implementations of system query functions
* system memory size in bytes
* system architecture is 64bit?
* CPU architecture is 64bit?
Diffstat (limited to 'libraries/ganalytics/src/sys_unix.cpp')
-rw-r--r-- | libraries/ganalytics/src/sys_unix.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libraries/ganalytics/src/sys_unix.cpp b/libraries/ganalytics/src/sys_unix.cpp index b4dd9b2b..9569fbb6 100644 --- a/libraries/ganalytics/src/sys_unix.cpp +++ b/libraries/ganalytics/src/sys_unix.cpp @@ -1,6 +1,7 @@ #include "sys.h" #include <sys/utsname.h> +#include <fstream> QString Sys::getSystemInfo() { @@ -11,3 +12,38 @@ QString Sys::getSystemInfo() return system + "; " + release; } + +uint64_t Sys::getSystemRam() +{ + std::string token; + std::ifstream file("/proc/meminfo"); + while(file >> token) + { + if(token == "MemTotal:") + { + uint64_t mem; + if(file >> mem) + { + return mem * 1024ull; + } + else + { + return 0; + } + } + // ignore rest of the line + file.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); + } + return 0; // nothing found +} + +bool Sys::isCPU64bit() +{ + return isSystem64bit(); +} + +bool Sys::isSystem64bit() +{ + // kernel build arch on linux + return QSysInfo::currentCpuArchitecture() == "x86_64"; +} |