2016-11-20 17:02:27 +05:30
|
|
|
#include "sys.h"
|
|
|
|
|
2016-11-26 06:48:05 +05:30
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
2021-09-05 00:57:09 +05:30
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
2021-09-05 01:40:57 +05:30
|
|
|
#include <QDebug>
|
2021-09-05 00:57:09 +05:30
|
|
|
|
2016-11-26 06:48:05 +05:30
|
|
|
Sys::KernelInfo Sys::getKernelInfo()
|
2016-11-20 17:02:27 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
Sys::KernelInfo out;
|
|
|
|
struct utsname buf;
|
|
|
|
uname(&buf);
|
2021-09-05 00:57:09 +05:30
|
|
|
out.kernelType = KernelType::Darwin;
|
2018-07-15 18:21:05 +05:30
|
|
|
out.kernelName = buf.sysname;
|
2021-09-05 00:57:09 +05:30
|
|
|
QString release = out.kernelVersion = buf.release;
|
|
|
|
|
|
|
|
// TODO: figure out how to detect cursed-ness (macOS emulated on linux via mad hacks and so on)
|
|
|
|
out.isCursed = false;
|
|
|
|
|
|
|
|
out.kernelMajor = 0;
|
|
|
|
out.kernelMinor = 0;
|
|
|
|
out.kernelPatch = 0;
|
|
|
|
auto sections = release.split('-');
|
|
|
|
if(sections.size() >= 1) {
|
|
|
|
auto versionParts = sections[0].split('.');
|
2021-09-05 01:40:57 +05:30
|
|
|
if(versionParts.size() >= 3) {
|
2021-09-05 01:48:29 +05:30
|
|
|
out.kernelMajor = versionParts[0].toInt();
|
|
|
|
out.kernelMinor = versionParts[1].toInt();
|
|
|
|
out.kernelPatch = versionParts[2].toInt();
|
2021-09-05 00:57:09 +05:30
|
|
|
}
|
2021-09-05 01:40:57 +05:30
|
|
|
else {
|
|
|
|
qWarning() << "Not enough version numbers in " << sections[0] << " found " << versionParts.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
qWarning() << "Not enough '-' sections in " << release << " found " << sections.size();
|
2021-09-05 00:57:09 +05:30
|
|
|
}
|
2018-07-15 18:21:05 +05:30
|
|
|
return out;
|
2016-11-20 17:02:27 +05:30
|
|
|
}
|
2016-11-22 05:27:15 +05:30
|
|
|
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
uint64_t Sys::getSystemRam()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
uint64_t memsize;
|
|
|
|
size_t memsizesize = sizeof(memsize);
|
|
|
|
if(!sysctlbyname("hw.memsize", &memsize, &memsizesize, NULL, 0))
|
|
|
|
{
|
|
|
|
return memsize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2016-11-22 05:27:15 +05:30
|
|
|
}
|
|
|
|
|
2018-03-12 03:30:54 +05:30
|
|
|
Sys::DistributionInfo Sys::getDistributionInfo()
|
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
DistributionInfo result;
|
|
|
|
return result;
|
2018-03-12 03:30:54 +05:30
|
|
|
}
|