summaryrefslogtreecommitdiffstats
path: root/platform/linuxbsd/os_linuxbsd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linuxbsd/os_linuxbsd.cpp')
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp67
1 files changed, 36 insertions, 31 deletions
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 8d8c8ce27b..ebdbd061d1 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -35,17 +35,13 @@
#include "main/main.h"
#include "servers/display_server.h"
-#include "modules/modules_enabled.gen.h" // For regex.
-#ifdef MODULE_REGEX_ENABLED
-#include "modules/regex/regex.h"
-#endif
-
#ifdef X11_ENABLED
#include "x11/display_server_x11.h"
#endif
-#ifdef HAVE_MNTENT
-#include <mntent.h>
+#include "modules/modules_enabled.gen.h" // For regex.
+#ifdef MODULE_REGEX_ENABLED
+#include "modules/regex/regex.h"
#endif
#include <dlfcn.h>
@@ -57,6 +53,10 @@
#include <sys/utsname.h>
#include <unistd.h>
+#ifdef HAVE_MNTENT
+#include <mntent.h>
+#endif
+
void OS_LinuxBSD::alert(const String &p_alert, const String &p_title) {
const char *message_programs[] = { "zenity", "kdialog", "Xdialog", "xmessage" };
@@ -215,48 +215,54 @@ String OS_LinuxBSD::get_name() const {
}
String OS_LinuxBSD::get_systemd_os_release_info_value(const String &key) const {
- static String info;
- if (info.is_empty()) {
- Ref<FileAccess> f = FileAccess::open("/etc/os-release", FileAccess::READ);
- if (f.is_valid()) {
- while (!f->eof_reached()) {
- const String line = f->get_line();
- if (line.find(key) != -1) {
- return line.split("=")[1].strip_edges();
- }
+ Ref<FileAccess> f = FileAccess::open("/etc/os-release", FileAccess::READ);
+ if (f.is_valid()) {
+ while (!f->eof_reached()) {
+ const String line = f->get_line();
+ if (line.find(key) != -1) {
+ String value = line.split("=")[1].strip_edges();
+ value = value.trim_prefix("\"");
+ return value.trim_suffix("\"");
}
}
}
- return info;
+ return "";
}
String OS_LinuxBSD::get_distribution_name() const {
- static String systemd_name = get_systemd_os_release_info_value("NAME"); // returns a value for systemd users, otherwise an empty string.
- if (!systemd_name.is_empty()) {
- return systemd_name;
+ static String distribution_name = get_systemd_os_release_info_value("NAME"); // returns a value for systemd users, otherwise an empty string.
+ if (!distribution_name.is_empty()) {
+ return distribution_name;
}
struct utsname uts; // returns a decent value for BSD family.
uname(&uts);
- return uts.sysname;
+ distribution_name = uts.sysname;
+ return distribution_name;
}
String OS_LinuxBSD::get_version() const {
- static String systemd_version = get_systemd_os_release_info_value("VERSION"); // returns a value for systemd users, otherwise an empty string.
- if (!systemd_version.is_empty()) {
- return systemd_version;
+ static String release_version = get_systemd_os_release_info_value("VERSION"); // returns a value for systemd users, otherwise an empty string.
+ if (!release_version.is_empty()) {
+ return release_version;
}
struct utsname uts; // returns a decent value for BSD family.
uname(&uts);
- return uts.version;
+ release_version = uts.version;
+ return release_version;
}
Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
- if (RenderingServer::get_singleton()->get_rendering_device() == nullptr) {
+ if (RenderingServer::get_singleton() == nullptr) {
return Vector<String>();
}
- const String rendering_device_name = RenderingServer::get_singleton()->get_rendering_device()->get_device_name(); // e.g. `NVIDIA GeForce GTX 970`
- const String rendering_device_vendor = RenderingServer::get_singleton()->get_rendering_device()->get_device_vendor_name(); // e.g. `NVIDIA`
+ static Vector<String> info;
+ if (!info.is_empty()) {
+ return info;
+ }
+
+ const String rendering_device_name = RenderingServer::get_singleton()->get_video_adapter_name(); // e.g. `NVIDIA GeForce GTX 970`
+ const String rendering_device_vendor = RenderingServer::get_singleton()->get_video_adapter_vendor(); // e.g. `NVIDIA`
const String card_name = rendering_device_name.trim_prefix(rendering_device_vendor).strip_edges(); // -> `GeForce GTX 970`
String vendor_device_id_mappings;
@@ -320,8 +326,8 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
Vector<String> class_display_device_drivers = OS_LinuxBSD::lspci_get_device_value(class_display_device_candidates, kernel_lit, dummys);
Vector<String> class_3d_device_drivers = OS_LinuxBSD::lspci_get_device_value(class_3d_device_candidates, kernel_lit, dummys);
- static String driver_name;
- static String driver_version;
+ String driver_name;
+ String driver_version;
// Use first valid value:
for (const String &driver : class_3d_device_drivers) {
@@ -341,7 +347,6 @@ Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
}
}
- Vector<String> info;
info.push_back(driver_name);
String modinfo;