Repository: godotengine/godot
File: platform/linuxbsd/os_linuxbsd.cpp (C++)

Code before:
	return "OpenBSD";
#else
	return "BSD";
#endif
}

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();
				}
			}
		}
	}
	return info;
}

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;
	}
	struct utsname uts; // returns a decent value for BSD family.
	uname(&uts);
	return uts.sysname;
}

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;
	}
	struct utsname uts; // returns a decent value for BSD family.
	uname(&uts);
	return uts.version;
}

Vector<String> OS_LinuxBSD::get_video_adapter_driver_info() const {
	if (RenderingServer::get_singleton()->get_rendering_device() == 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`
	const String card_name = rendering_device_name.trim_prefix(rendering_device_vendor).strip_edges(); // -> `GeForce GTX 970`


Review comment (bug):
`static` is used for something which is global/reusable in the class, as a cache system. So if you always re-assign it a new string, there's no point in making it static. It's only useful in this kind of construct:
```cpp
static String some_string;
if (some_string.is_empty()) { // True the first time, won't be true next time so we skip the calculation.
    some_string = some_complex_method();
}
return some_string;
```

Here `static` can make sense to avoid opening OS files repeatedly for information that won't change, but it's a bit trickier as you also have a fallback system for non-systemd systems. So the whole logic should be something like this:

```cpp
static String distribution_name;
if (!distribution_name.is_empty()) {
	return distribution_name;
}

// Check first if systemd has the info.
distribution_name = get_systemd_os_release_info_value("NAME");
if (!distribution_name.is_empty()) {
	return distribution_name;
}

// Otherwise utsname can provide a decent value for BSD family.
struct utsname uts; 
uname(&uts);
distribution_name = uts.sysname;
if (!distribution_name.is_empty()) {
	return distribution_name;
}

// Just in case all failed, assign a fallback.
distribution_name = "<unknown>";

return distribution_name;
```

Same for `get_version`.

Code after:
	return "OpenBSD";
#else
	return "BSD";
#endif
}

String OS_LinuxBSD::get_systemd_os_release_info_value(const String &key) const {
	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 "";
}

String OS_LinuxBSD::get_distribution_name() const {
	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);
	distribution_name = uts.sysname;
	return distribution_name;
}

String OS_LinuxBSD::get_version() const {
	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);
	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) {
		return Vector<String>();
	}

	static Vector<String> info;
	if (!info.is_empty()) {
		return info;