From f181a5db757d6880e3d47d6de7c988ee9f06871b Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 6 Apr 2021 22:53:06 +0200 Subject: [PATCH] Add compatibility OS detection with uname --- plugins/editor/src/editor/NativeHelpers.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/editor/src/editor/NativeHelpers.cpp b/plugins/editor/src/editor/NativeHelpers.cpp index 714db433..336c81d6 100644 --- a/plugins/editor/src/editor/NativeHelpers.cpp +++ b/plugins/editor/src/editor/NativeHelpers.cpp @@ -117,6 +117,7 @@ std::string getOperatingSystemName() #include #include #include +#include #include #include #include @@ -216,6 +217,7 @@ std::string getOperatingSystemName() std::string name; name.reserve(256); +#if GLIB_CHECK_VERSION(2, 64, 0) if (char *osName = g_get_os_info(G_OS_INFO_KEY_NAME)) { name.append(osName); g_free(osName); @@ -229,6 +231,19 @@ std::string getOperatingSystemName() name.append(osVersion); g_free(osVersion); } +#else + utsname un {}; + int ret = uname(&un); + if (ret != -1 && un.sysname[0] != '\0') + name.append(un.sysname); + else { + name.append("Unknown"); + } + if (ret != -1 && un.release[0] != '\0') { + name.push_back(' '); + name.append(un.release); + } +#endif return name; }