mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-04 09:08:42 +00:00
NOISSUE add implementations of system query functions
* system memory size in bytes * system architecture is 64bit? * CPU architecture is 64bit?
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
Reference in New Issue
Block a user