GH-4014 change updater to recognize new Qt 5.15.2 builds
This commit is contained in:
@ -4,10 +4,24 @@
|
||||
namespace Sys
|
||||
{
|
||||
const uint64_t mebibyte = 1024ull * 1024ull;
|
||||
|
||||
enum class KernelType {
|
||||
Undetermined,
|
||||
Windows,
|
||||
Darwin,
|
||||
Linux
|
||||
};
|
||||
|
||||
struct KernelInfo
|
||||
{
|
||||
QString kernelName;
|
||||
QString kernelVersion;
|
||||
|
||||
KernelType kernelType = KernelType::Undetermined;
|
||||
int kernelMajor = 0;
|
||||
int kernelMinor = 0;
|
||||
int kernelPatch = 0;
|
||||
bool isCursed = false;
|
||||
};
|
||||
|
||||
KernelInfo getKernelInfo();
|
||||
|
@ -2,13 +2,33 @@
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
Sys::KernelInfo Sys::getKernelInfo()
|
||||
{
|
||||
Sys::KernelInfo out;
|
||||
struct utsname buf;
|
||||
uname(&buf);
|
||||
out.kernelType = KernelType::Darwin;
|
||||
out.kernelName = buf.sysname;
|
||||
out.kernelVersion = buf.release;
|
||||
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('.');
|
||||
if(sections.size() >= 3) {
|
||||
out.kernelMajor = sections[0].toInt();
|
||||
out.kernelMinor = sections[1].toInt();
|
||||
out.kernelPatch = sections[2].toInt();
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,34 @@
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
Sys::KernelInfo Sys::getKernelInfo()
|
||||
{
|
||||
Sys::KernelInfo out;
|
||||
struct utsname buf;
|
||||
uname(&buf);
|
||||
// NOTE: we assume linux here. this needs further elaboration
|
||||
out.kernelType = KernelType::Linux;
|
||||
out.kernelName = buf.sysname;
|
||||
out.kernelVersion = buf.release;
|
||||
QString release = out.kernelVersion = buf.release;
|
||||
|
||||
// linux binary running on WSL is cursed.
|
||||
out.isCursed = release.contains("WSL", Qt::CaseInsensitive) || release.contains("Microsoft", Qt::CaseInsensitive);
|
||||
|
||||
out.kernelMajor = 0;
|
||||
out.kernelMinor = 0;
|
||||
out.kernelPatch = 0;
|
||||
auto sections = release.split('-');
|
||||
if(sections.size() >= 1) {
|
||||
auto versionParts = sections[0].split('.');
|
||||
if(sections.size() >= 3) {
|
||||
out.kernelMajor = sections[0].toInt();
|
||||
out.kernelMinor = sections[1].toInt();
|
||||
out.kernelPatch = sections[2].toInt();
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,16 @@
|
||||
Sys::KernelInfo Sys::getKernelInfo()
|
||||
{
|
||||
Sys::KernelInfo out;
|
||||
out.kernelType = KernelType::Windows;
|
||||
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);
|
||||
out.kernelMajor = osvi.dwMajorVersion;
|
||||
out.kernelMinor = osvi.dwMinorVersion;
|
||||
out.kernelPatch = osvi.dwBuildNumber;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user