2016-11-20 11:32:27 +00:00
|
|
|
#include "sys.h"
|
|
|
|
|
|
|
|
#include <sys/utsname.h>
|
2016-11-21 23:57:15 +00:00
|
|
|
#include <fstream>
|
2016-11-20 11:32:27 +00:00
|
|
|
|
2016-11-26 01:18:05 +00:00
|
|
|
Sys::KernelInfo Sys::getKernelInfo()
|
2016-11-20 11:32:27 +00:00
|
|
|
{
|
2016-11-26 01:18:05 +00:00
|
|
|
Sys::KernelInfo out;
|
2016-11-20 11:32:27 +00:00
|
|
|
struct utsname buf;
|
|
|
|
uname(&buf);
|
2016-11-26 01:18:05 +00:00
|
|
|
out.kernelName = buf.sysname;
|
|
|
|
out.kernelVersion = buf.release;
|
|
|
|
return out;
|
2016-11-20 11:32:27 +00:00
|
|
|
}
|
2016-11-21 23:57:15 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
}
|