| 7 | #include <QDebug> |
| 8 | |
| 9 | Sys::KernelInfo Sys::getKernelInfo() |
| 10 | { |
| 11 | Sys::KernelInfo out; |
| 12 | struct utsname buf; |
| 13 | uname(&buf); |
| 14 | out.kernelType = KernelType::Darwin; |
| 15 | out.kernelName = buf.sysname; |
| 16 | QString release = out.kernelVersion = buf.release; |
| 17 | |
| 18 | // TODO: figure out how to detect cursed-ness (macOS emulated on linux via mad hacks and so on) |
| 19 | out.isCursed = false; |
| 20 | |
| 21 | out.kernelMajor = 0; |
| 22 | out.kernelMinor = 0; |
| 23 | out.kernelPatch = 0; |
| 24 | auto sections = release.split('-'); |
| 25 | if(sections.size() >= 1) { |
| 26 | auto versionParts = sections[0].split('.'); |
| 27 | if(versionParts.size() >= 3) { |
| 28 | out.kernelMajor = versionParts[0].toInt(); |
| 29 | out.kernelMinor = versionParts[1].toInt(); |
| 30 | out.kernelPatch = versionParts[2].toInt(); |
| 31 | } |
| 32 | else { |
| 33 | qWarning() << "Not enough version numbers in " << sections[0] << " found " << versionParts.size(); |
| 34 | } |
| 35 | } |
| 36 | else { |
| 37 | qWarning() << "Not enough '-' sections in " << release << " found " << sections.size(); |
| 38 | } |
| 39 | return out; |
| 40 | } |
| 41 | |
| 42 | #include <sys/sysctl.h> |
| 43 | |