summaryrefslogtreecommitdiffstats
path: root/libraries/systeminfo
diff options
context:
space:
mode:
authorThomas Groman <tgroman@nuegia.net>2019-09-19 00:41:48 -0700
committerThomas Groman <tgroman@nuegia.net>2019-09-19 00:41:48 -0700
commit32b3ed0a1362a4b0798ad71fac3450fb77cb7e41 (patch)
tree7be7a2f602e6a5af7bc2db86bef9cf2a659c3d3d /libraries/systeminfo
parent5fb2c6334e7d5237db11695b4c0ec0f2d1e47c88 (diff)
downloadMultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar.gz
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar.lz
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.tar.xz
MultiMC-32b3ed0a1362a4b0798ad71fac3450fb77cb7e41.zip
merged from 0.6.7 codebase
Diffstat (limited to 'libraries/systeminfo')
-rw-r--r--libraries/systeminfo/CMakeLists.txt18
-rw-r--r--libraries/systeminfo/include/distroutils.h8
-rw-r--r--libraries/systeminfo/include/sys.h50
-rw-r--r--libraries/systeminfo/src/distroutils.cpp418
-rw-r--r--libraries/systeminfo/src/sys_apple.cpp44
-rw-r--r--libraries/systeminfo/src/sys_test.cpp28
-rw-r--r--libraries/systeminfo/src/sys_unix.cpp98
-rw-r--r--libraries/systeminfo/src/sys_win32.cpp50
8 files changed, 357 insertions, 357 deletions
diff --git a/libraries/systeminfo/CMakeLists.txt b/libraries/systeminfo/CMakeLists.txt
index 393b5318..548a589c 100644
--- a/libraries/systeminfo/CMakeLists.txt
+++ b/libraries/systeminfo/CMakeLists.txt
@@ -9,21 +9,21 @@ src/distroutils.cpp
)
if (WIN32)
- list(APPEND systeminfo_SOURCES src/sys_win32.cpp)
+ list(APPEND systeminfo_SOURCES src/sys_win32.cpp)
elseif (UNIX)
- if(APPLE)
- list(APPEND systeminfo_SOURCES src/sys_apple.cpp)
- else()
- list(APPEND systeminfo_SOURCES src/sys_unix.cpp)
- endif()
+ if(APPLE)
+ list(APPEND systeminfo_SOURCES src/sys_apple.cpp)
+ else()
+ list(APPEND systeminfo_SOURCES src/sys_unix.cpp)
+ endif()
endif()
add_library(systeminfo STATIC ${systeminfo_SOURCES})
-qt5_use_modules(systeminfo Core Gui Network)
+target_link_libraries(systeminfo Qt5::Core Qt5::Gui Qt5::Network)
target_include_directories(systeminfo PUBLIC include)
include (UnitTest)
add_unit_test(sys
- SOURCES src/sys_test.cpp
- LIBS systeminfo
+ SOURCES src/sys_test.cpp
+ LIBS systeminfo
)
diff --git a/libraries/systeminfo/include/distroutils.h b/libraries/systeminfo/include/distroutils.h
index 5ff8d591..2e85f433 100644
--- a/libraries/systeminfo/include/distroutils.h
+++ b/libraries/systeminfo/include/distroutils.h
@@ -4,10 +4,10 @@
namespace Sys {
struct LsbInfo
{
- QString distributor;
- QString version;
- QString description;
- QString codename;
+ QString distributor;
+ QString version;
+ QString description;
+ QString codename;
};
bool main_lsb_info(LsbInfo & out);
diff --git a/libraries/systeminfo/include/sys.h b/libraries/systeminfo/include/sys.h
index c573eb53..7980dfdf 100644
--- a/libraries/systeminfo/include/sys.h
+++ b/libraries/systeminfo/include/sys.h
@@ -6,37 +6,37 @@ namespace Sys
const uint64_t megabyte = 1024ull * 1024ull;
struct KernelInfo
{
- QString kernelName;
- QString kernelVersion;
+ QString kernelName;
+ QString kernelVersion;
};
KernelInfo getKernelInfo();
struct DistributionInfo
{
- DistributionInfo operator+(const DistributionInfo& rhs) const
- {
- DistributionInfo out;
- if(!distributionName.isEmpty())
- {
- out.distributionName = distributionName;
- }
- else
- {
- out.distributionName = rhs.distributionName;
- }
- if(!distributionVersion.isEmpty())
- {
- out.distributionVersion = distributionVersion;
- }
- else
- {
- out.distributionVersion = rhs.distributionVersion;
- }
- return out;
- }
- QString distributionName;
- QString distributionVersion;
+ DistributionInfo operator+(const DistributionInfo& rhs) const
+ {
+ DistributionInfo out;
+ if(!distributionName.isEmpty())
+ {
+ out.distributionName = distributionName;
+ }
+ else
+ {
+ out.distributionName = rhs.distributionName;
+ }
+ if(!distributionVersion.isEmpty())
+ {
+ out.distributionVersion = distributionVersion;
+ }
+ else
+ {
+ out.distributionVersion = rhs.distributionVersion;
+ }
+ return out;
+ }
+ QString distributionName;
+ QString distributionVersion;
};
DistributionInfo getDistributionInfo();
diff --git a/libraries/systeminfo/src/distroutils.cpp b/libraries/systeminfo/src/distroutils.cpp
index cdba05d0..fb9ae25d 100644
--- a/libraries/systeminfo/src/distroutils.cpp
+++ b/libraries/systeminfo/src/distroutils.cpp
@@ -41,243 +41,243 @@ SOFTWARE.
Sys::DistributionInfo Sys::read_os_release()
{
- Sys::DistributionInfo out;
- QStringList files = { "/etc/os-release", "/usr/lib/os-release" };
- QString name;
- QString version;
- for (auto &file: files)
- {
- if(!QFile::exists(file))
- {
- continue;
- }
- QSettings settings(file, QSettings::IniFormat);
- if(settings.contains("ID"))
- {
- name = settings.value("ID").toString().toLower();
- }
- else if (settings.contains("NAME"))
- {
- name = settings.value("NAME").toString().toLower();
- }
- else
- {
- continue;
- }
+ Sys::DistributionInfo out;
+ QStringList files = { "/etc/os-release", "/usr/lib/os-release" };
+ QString name;
+ QString version;
+ for (auto &file: files)
+ {
+ if(!QFile::exists(file))
+ {
+ continue;
+ }
+ QSettings settings(file, QSettings::IniFormat);
+ if(settings.contains("ID"))
+ {
+ name = settings.value("ID").toString().toLower();
+ }
+ else if (settings.contains("NAME"))
+ {
+ name = settings.value("NAME").toString().toLower();
+ }
+ else
+ {
+ continue;
+ }
- if(settings.contains("VERSION_ID"))
- {
- version = settings.value("VERSION_ID").toString().toLower();
- }
- else if(settings.contains("VERSION"))
- {
- version = settings.value("VERSION").toString().toLower();
- }
- break;
- }
- if(name.isEmpty())
- {
- return out;
- }
- out.distributionName = name;
- out.distributionVersion = version;
- return out;
+ if(settings.contains("VERSION_ID"))
+ {
+ version = settings.value("VERSION_ID").toString().toLower();
+ }
+ else if(settings.contains("VERSION"))
+ {
+ version = settings.value("VERSION").toString().toLower();
+ }
+ break;
+ }
+ if(name.isEmpty())
+ {
+ return out;
+ }
+ out.distributionName = name;
+ out.distributionVersion = version;
+ return out;
}
bool Sys::main_lsb_info(Sys::LsbInfo & out)
{
- int status=0;
- QProcess lsbProcess;
- lsbProcess.start("lsb_release -a");
- lsbProcess.waitForFinished();
- status = lsbProcess.exitStatus();
- QString output = lsbProcess.readAllStandardOutput();
- qDebug() << output;
- lsbProcess.close();
- if(status == 0)
- {
- auto lines = output.split('\n');
- for(auto line:lines)
- {
- int index = line.indexOf(':');
- auto key = line.left(index).trimmed();
- auto value = line.mid(index + 1).toLower().trimmed();
- if(key == "Distributor ID")
- out.distributor = value;
- else if(key == "Release")
- out.version = value;
- else if(key == "Description")
- out.description = value;
- else if(key == "Codename")
- out.codename = value;
- }
- return !out.distributor.isEmpty();
- }
- return false;
+ int status=0;
+ QProcess lsbProcess;
+ lsbProcess.start("lsb_release -a");
+ lsbProcess.waitForFinished();
+ status = lsbProcess.exitStatus();
+ QString output = lsbProcess.readAllStandardOutput();
+ qDebug() << output;
+ lsbProcess.close();
+ if(status == 0)
+ {
+ auto lines = output.split('\n');
+ for(auto line:lines)
+ {
+ int index = line.indexOf(':');
+ auto key = line.left(index).trimmed();
+ auto value = line.mid(index + 1).toLower().trimmed();
+ if(key == "Distributor ID")
+ out.distributor = value;
+ else if(key == "Release")
+ out.version = value;
+ else if(key == "Description")
+ out.description = value;
+ else if(key == "Codename")
+ out.codename = value;
+ }
+ return !out.distributor.isEmpty();
+ }
+ return false;
}
bool Sys::fallback_lsb_info(Sys::LsbInfo & out)
{
- // running lsb_release failed, try to read the file instead
- // /etc/lsb-release format, if the file even exists, is non-standard.
- // Only the `lsb_release` command is specified by LSB. Nonetheless, some
- // distributions install an /etc/lsb-release as part of the base
- // distribution, but `lsb_release` remains optional.
- QString file = "/etc/lsb-release";
- if (QFile::exists(file))
- {
- QSettings settings(file, QSettings::IniFormat);
- if(settings.contains("DISTRIB_ID"))
- {
- out.distributor = settings.value("DISTRIB_ID").toString().toLower();
- }
- if(settings.contains("DISTRIB_RELEASE"))
- {
- out.version = settings.value("DISTRIB_RELEASE").toString().toLower();
- }
- return !out.distributor.isEmpty();
- }
- return false;
+ // running lsb_release failed, try to read the file instead
+ // /etc/lsb-release format, if the file even exists, is non-standard.
+ // Only the `lsb_release` command is specified by LSB. Nonetheless, some
+ // distributions install an /etc/lsb-release as part of the base
+ // distribution, but `lsb_release` remains optional.
+ QString file = "/etc/lsb-release";
+ if (QFile::exists(file))
+ {
+ QSettings settings(file, QSettings::IniFormat);
+ if(settings.contains("DISTRIB_ID"))
+ {
+ out.distributor = settings.value("DISTRIB_ID").toString().toLower();
+ }
+ if(settings.contains("DISTRIB_RELEASE"))
+ {
+ out.version = settings.value("DISTRIB_RELEASE").toString().toLower();
+ }
+ return !out.distributor.isEmpty();
+ }
+ return false;
}
void Sys::lsb_postprocess(Sys::LsbInfo & lsb, Sys::DistributionInfo & out)
{
- QString dist = lsb.distributor;
- QString vers = lsb.version;
- if(dist.startsWith("redhatenterprise"))
- {
- dist = "rhel";
- }
- else if(dist == "archlinux")
- {
- dist = "arch";
- }
- else if (dist.startsWith("suse"))
- {
- if(lsb.description.startsWith("opensuse"))
- {
- dist = "opensuse";
- }
- else if (lsb.description.startsWith("suse linux enterprise"))
- {
- dist = "sles";
- }
- }
- else if (dist == "debian" and vers == "testing")
- {
- vers = lsb.codename;
- }
- else
- {
- // ubuntu, debian, gentoo, scientific, slackware, ... ?
- auto parts = dist.split(QRegExp("\\s+"), QString::SkipEmptyParts);
- if(parts.size())
- {
- dist = parts[0];
- }
- }
- if(!dist.isEmpty())
- {
- out.distributionName = dist;
- out.distributionVersion = vers;
- }
+ QString dist = lsb.distributor;
+ QString vers = lsb.version;
+ if(dist.startsWith("redhatenterprise"))
+ {
+ dist = "rhel";
+ }
+ else if(dist == "archlinux")
+ {
+ dist = "arch";
+ }
+ else if (dist.startsWith("suse"))
+ {
+ if(lsb.description.startsWith("opensuse"))
+ {
+ dist = "opensuse";
+ }
+ else if (lsb.description.startsWith("suse linux enterprise"))
+ {
+ dist = "sles";
+ }
+ }
+ else if (dist == "debian" and vers == "testing")
+ {
+ vers = lsb.codename;
+ }
+ else
+ {
+ // ubuntu, debian, gentoo, scientific, slackware, ... ?
+ auto parts = dist.split(QRegExp("\\s+"), QString::SkipEmptyParts);
+ if(parts.size())
+ {
+ dist = parts[0];
+ }
+ }
+ if(!dist.isEmpty())
+ {
+ out.distributionName = dist;
+ out.distributionVersion = vers;
+ }
}
Sys::DistributionInfo Sys::read_lsb_release()
{
- LsbInfo lsb;
- if(!main_lsb_info(lsb))
- {
- if(!fallback_lsb_info(lsb))
- {
- return Sys::DistributionInfo();
- }
- }
- Sys::DistributionInfo out;
- lsb_postprocess(lsb, out);
- return out;
+ LsbInfo lsb;
+ if(!main_lsb_info(lsb))
+ {
+ if(!fallback_lsb_info(lsb))
+ {
+ return Sys::DistributionInfo();
+ }
+ }
+ Sys::DistributionInfo out;
+ lsb_postprocess(lsb, out);
+ return out;
}
QString Sys::_extract_distribution(const QString & x)
{
- QString release = x.toLower();
- if (release.startsWith("red hat enterprise"))
- {
- return "rhel";
- }
- if (release.startsWith("suse linux enterprise"))
- {
- return "sles";
- }
- QStringList list = release.split(QRegExp("\\s+"), QString::SkipEmptyParts);
- if(list.size())
- {
- return list[0];
- }
- return QString();
+ QString release = x.toLower();
+ if (release.startsWith("red hat enterprise"))
+ {
+ return "rhel";
+ }
+ if (release.startsWith("suse linux enterprise"))
+ {
+ return "sles";
+ }
+ QStringList list = release.split(QRegExp("\\s+"), QString::SkipEmptyParts);
+ if(list.size())
+ {
+ return list[0];
+ }
+ return QString();
}
QString Sys::_extract_version(const QString & x)
{
- QRegExp versionish_string("\\d+(?:\\.\\d+)*$");
- QStringList list = x.split(QRegExp("\\s+"), QString::SkipEmptyParts);
- for(int i = list.size() - 1; i >= 0; --i)
- {
- QString chunk = list[i];
- if(versionish_string.exactMatch(chunk))
- {
- return chunk;
- }
- }
- return QString();
+ QRegExp versionish_string("\\d+(?:\\.\\d+)*$");
+ QStringList list = x.split(QRegExp("\\s+"), QString::SkipEmptyParts);
+ for(int i = list.size() - 1; i >= 0; --i)
+ {
+ QString chunk = list[i];
+ if(versionish_string.exactMatch(chunk))
+ {
+ return chunk;
+ }
+ }
+ return QString();
}
Sys::DistributionInfo Sys::read_legacy_release()
{
- struct checkEntry
- {
- QString file;
- std::function<QString(const QString &)> extract_distro;
- std::function<QString(const QString &)> extract_version;
- };
- QList<checkEntry> checks =
- {
- {"/etc/arch-release", [](const QString &){ return "arch";}, [](const QString &){ return "rolling";}},
- {"/etc/slackware-version", &Sys::_extract_distribution, &Sys::_extract_version},
- {QString(), &Sys::_extract_distribution, &Sys::_extract_version},
- {"/etc/debian_version", [](const QString &){ return "debian";}, [](const QString & x){ return x;}},
- };
- for(auto & check: checks)
- {
- QStringList files;
- if(check.file.isNull())
- {
- QDir etcDir("/etc");
- etcDir.setNameFilters({"*-release"});
- etcDir.setFilter(QDir::Files | QDir::NoDot | QDir::NoDotDot | QDir::Readable | QDir::Hidden);
- files = etcDir.entryList();
- }
- else
- {
- files.append(check.file);
- }
- for (auto file : files)
- {
- QFile relfile(file);
- if(!relfile.open(QIODevice::ReadOnly | QIODevice::Text))
- continue;
- QString contents = QString::fromUtf8(relfile.readLine()).trimmed();
- QString dist = check.extract_distro(contents);
- QString vers = check.extract_version(contents);
- if(!dist.isEmpty())
- {
- Sys::DistributionInfo out;
- out.distributionName = dist;
- out.distributionVersion = vers;
- return out;
- }
- }
- }
- return Sys::DistributionInfo();
+ struct checkEntry
+ {
+ QString file;
+ std::function<QString(const QString &)> extract_distro;
+ std::function<QString(const QString &)> extract_version;
+ };
+ QList<checkEntry> checks =
+ {
+ {"/etc/arch-release", [](const QString &){ return "arch";}, [](const QString &){ return "rolling";}},
+ {"/etc/slackware-version", &Sys::_extract_distribution, &Sys::_extract_version},
+ {QString(), &Sys::_extract_distribution, &Sys::_extract_version},
+ {"/etc/debian_version", [](const QString &){ return "debian";}, [](const QString & x){ return x;}},
+ };
+ for(auto & check: checks)
+ {
+ QStringList files;
+ if(check.file.isNull())
+ {
+ QDir etcDir("/etc");
+ etcDir.setNameFilters({"*-release"});
+ etcDir.setFilter(QDir::Files | QDir::NoDot | QDir::NoDotDot | QDir::Readable | QDir::Hidden);
+ files = etcDir.entryList();
+ }
+ else
+ {
+ files.append(check.file);
+ }
+ for (auto file : files)
+ {
+ QFile relfile(file);
+ if(!relfile.open(QIODevice::ReadOnly | QIODevice::Text))
+ continue;
+ QString contents = QString::fromUtf8(relfile.readLine()).trimmed();
+ QString dist = check.extract_distro(contents);
+ QString vers = check.extract_version(contents);
+ if(!dist.isEmpty())
+ {
+ Sys::DistributionInfo out;
+ out.distributionName = dist;
+ out.distributionVersion = vers;
+ return out;
+ }
+ }
+ }
+ return Sys::DistributionInfo();
}
diff --git a/libraries/systeminfo/src/sys_apple.cpp b/libraries/systeminfo/src/sys_apple.cpp
index 62e6037d..4bcffae4 100644
--- a/libraries/systeminfo/src/sys_apple.cpp
+++ b/libraries/systeminfo/src/sys_apple.cpp
@@ -4,44 +4,44 @@
Sys::KernelInfo Sys::getKernelInfo()
{
- Sys::KernelInfo out;
- struct utsname buf;
- uname(&buf);
- out.kernelName = buf.sysname;
- out.kernelVersion = buf.release;
- return out;
+ Sys::KernelInfo out;
+ struct utsname buf;
+ uname(&buf);
+ out.kernelName = buf.sysname;
+ out.kernelVersion = buf.release;
+ return out;
}
#include <sys/sysctl.h>
uint64_t Sys::getSystemRam()
{
- uint64_t memsize;
- size_t memsizesize = sizeof(memsize);
- if(!sysctlbyname("hw.memsize", &memsize, &memsizesize, NULL, 0))
- {
- return memsize;
- }
- else
- {
- return 0;
- }
+ uint64_t memsize;
+ size_t memsizesize = sizeof(memsize);
+ if(!sysctlbyname("hw.memsize", &memsize, &memsizesize, NULL, 0))
+ {
+ return memsize;
+ }
+ else
+ {
+ return 0;
+ }
}
bool Sys::isCPU64bit()
{
- // not even going to pretend I'm going to support anything else
- return true;
+ // not even going to pretend I'm going to support anything else
+ return true;
}
bool Sys::isSystem64bit()
{
- // yep. maybe when we have 128bit CPUs on consumer devices.
- return true;
+ // yep. maybe when we have 128bit CPUs on consumer devices.
+ return true;
}
Sys::DistributionInfo Sys::getDistributionInfo()
{
- DistributionInfo result;
- return result;
+ DistributionInfo result;
+ return result;
}
diff --git a/libraries/systeminfo/src/sys_test.cpp b/libraries/systeminfo/src/sys_test.cpp
index 5888e02b..315050d2 100644
--- a/libraries/systeminfo/src/sys_test.cpp
+++ b/libraries/systeminfo/src/sys_test.cpp
@@ -5,24 +5,24 @@
class SysTest : public QObject
{
- Q_OBJECT
+ Q_OBJECT
private
slots:
- void test_kernelNotNull()
- {
- auto kinfo = Sys::getKernelInfo();
- QVERIFY(!kinfo.kernelName.isEmpty());
- QVERIFY(kinfo.kernelVersion != "0.0");
- }
+ void test_kernelNotNull()
+ {
+ auto kinfo = Sys::getKernelInfo();
+ QVERIFY(!kinfo.kernelName.isEmpty());
+ QVERIFY(kinfo.kernelVersion != "0.0");
+ }
/*
- void test_systemDistroNotNull()
- {
- auto kinfo = Sys::getDistributionInfo();
- QVERIFY(!kinfo.distributionName.isEmpty());
- QVERIFY(!kinfo.distributionVersion.isEmpty());
- qDebug() << "Distro: " << kinfo.distributionName << "version" << kinfo.distributionVersion;
- }
+ void test_systemDistroNotNull()
+ {
+ auto kinfo = Sys::getDistributionInfo();
+ QVERIFY(!kinfo.distributionName.isEmpty());
+ QVERIFY(!kinfo.distributionVersion.isEmpty());
+ qDebug() << "Distro: " << kinfo.distributionName << "version" << kinfo.distributionVersion;
+ }
*/
};
diff --git a/libraries/systeminfo/src/sys_unix.cpp b/libraries/systeminfo/src/sys_unix.cpp
index 313908f3..ab3f302e 100644
--- a/libraries/systeminfo/src/sys_unix.cpp
+++ b/libraries/systeminfo/src/sys_unix.cpp
@@ -7,69 +7,69 @@
Sys::KernelInfo Sys::getKernelInfo()
{
- Sys::KernelInfo out;
- struct utsname buf;
- uname(&buf);
- out.kernelName = buf.sysname;
- out.kernelVersion = buf.release;
- return out;
+ 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
+ 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();
+ return isSystem64bit();
}
bool Sys::isSystem64bit()
{
- // kernel build arch on linux
- return QSysInfo::currentCpuArchitecture() == "x86_64";
+ // kernel build arch on linux
+ return QSysInfo::currentCpuArchitecture() == "x86_64";
}
Sys::DistributionInfo Sys::getDistributionInfo()
{
- DistributionInfo systemd_info = read_os_release();
- DistributionInfo lsb_info = read_lsb_release();
- DistributionInfo legacy_info = read_legacy_release();
- DistributionInfo result = systemd_info + lsb_info + legacy_info;
- if(result.distributionName.isNull())
- {
- result.distributionName = "unknown";
- }
- if(result.distributionVersion.isNull())
- {
- if(result.distributionName == "arch")
- {
- result.distributionVersion = "rolling";
- }
- else
- {
- result.distributionVersion = "unknown";
- }
- }
- return result;
+ DistributionInfo systemd_info = read_os_release();
+ DistributionInfo lsb_info = read_lsb_release();
+ DistributionInfo legacy_info = read_legacy_release();
+ DistributionInfo result = systemd_info + lsb_info + legacy_info;
+ if(result.distributionName.isNull())
+ {
+ result.distributionName = "unknown";
+ }
+ if(result.distributionVersion.isNull())
+ {
+ if(result.distributionName == "arch")
+ {
+ result.distributionVersion = "rolling";
+ }
+ else
+ {
+ result.distributionVersion = "unknown";
+ }
+ }
+ return result;
}
diff --git a/libraries/systeminfo/src/sys_win32.cpp b/libraries/systeminfo/src/sys_win32.cpp
index cc1d61c1..a750b3a7 100644
--- a/libraries/systeminfo/src/sys_win32.cpp
+++ b/libraries/systeminfo/src/sys_win32.cpp
@@ -4,49 +4,49 @@
Sys::KernelInfo Sys::getKernelInfo()
{
- Sys::KernelInfo out;
- out.kernelName = "Windows";
- OSVERSIONINFOW osvi;
- ZeroMemory(&osvi, sizeof(OSVERSIONINFOW));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
- GetVersionExW(&osvi);
- out.kernelVersion = QString("%1.%2").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion);
- return out;
+ Sys::KernelInfo out;
+ out.kernelName = "Windows";
+ OSVERSIONINFOW osvi;
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOW));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
+ GetVersionExW(&osvi);
+ out.kernelVersion = QString("%1.%2").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion);
+ return out;
}
uint64_t Sys::getSystemRam()
{
- MEMORYSTATUSEX status;
- status.dwLength = sizeof(status);
- GlobalMemoryStatusEx( &status );
- // bytes
- return (uint64_t)status.ullTotalPhys;
+ MEMORYSTATUSEX status;
+ status.dwLength = sizeof(status);
+ GlobalMemoryStatusEx( &status );
+ // bytes
+ return (uint64_t)status.ullTotalPhys;
}
bool Sys::isSystem64bit()
{
#if defined(_WIN64)
- return true;
+ return true;
#elif defined(_WIN32)
- BOOL f64 = false;
- return IsWow64Process(GetCurrentProcess(), &f64) && f64;
+ BOOL f64 = false;
+ return IsWow64Process(GetCurrentProcess(), &f64) && f64;
#else
- // it's some other kind of system...
- return false;
+ // it's some other kind of system...
+ return false;
#endif
}
bool Sys::isCPU64bit()
{
- SYSTEM_INFO info;
- ZeroMemory(&info, sizeof(SYSTEM_INFO));
- GetNativeSystemInfo(&info);
- auto arch = info.wProcessorArchitecture;
- return arch == PROCESSOR_ARCHITECTURE_AMD64 || arch == PROCESSOR_ARCHITECTURE_IA64;
+ SYSTEM_INFO info;
+ ZeroMemory(&info, sizeof(SYSTEM_INFO));
+ GetNativeSystemInfo(&info);
+ auto arch = info.wProcessorArchitecture;
+ return arch == PROCESSOR_ARCHITECTURE_AMD64 || arch == PROCESSOR_ARCHITECTURE_IA64;
}
Sys::DistributionInfo Sys::getDistributionInfo()
{
- DistributionInfo result;
- return result;
+ DistributionInfo result;
+ return result;
}