diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-01-01 19:59:46 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-01-01 20:04:08 +0100 |
commit | a666dc0a1afa69b5b42aa3a487c8fa971c01cde1 (patch) | |
tree | e226954e1af8f1dce0f9e73898331aef2481503b /libraries/systeminfo/src/sys_unix.cpp | |
parent | 722896d41f15a8bc78a864f7adcfd0527648073c (diff) | |
download | PrismLauncher-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.tar.gz PrismLauncher-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.tar.bz2 PrismLauncher-a666dc0a1afa69b5b42aa3a487c8fa971c01cde1.zip |
NOISSUE fix up translation selection in settings and add OS/sys arch reporting
Diffstat (limited to 'libraries/systeminfo/src/sys_unix.cpp')
-rw-r--r-- | libraries/systeminfo/src/sys_unix.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libraries/systeminfo/src/sys_unix.cpp b/libraries/systeminfo/src/sys_unix.cpp new file mode 100644 index 00000000..866c9fdb --- /dev/null +++ b/libraries/systeminfo/src/sys_unix.cpp @@ -0,0 +1,49 @@ +#include "sys.h" + +#include <sys/utsname.h> +#include <fstream> + +Sys::KernelInfo Sys::getKernelInfo() +{ + Sys::KernelInfo out; + struct utsname buf; + uname(&buf); + out.kernelName = buf.sysname; + out.kernelVersion = buf.release; + return out; +} + +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"; +} |