1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Add an OS.get_processor_name() method

This method can be used to get the CPU model name.
It can be used in conjunction with
`RenderingServer.get_video_adapter_name()` and
`RenderingServer.get_video_adapter_vendor()` for annotating benchmarks
and automatic graphics quality configuration.
This commit is contained in:
Hugo Locurcio
2020-12-27 01:50:21 +01:00
parent 171021145d
commit ee7cd9a3a1
13 changed files with 78 additions and 1 deletions

View File

@@ -141,6 +141,20 @@ String OS_LinuxBSD::get_unique_id() const {
return machine_id;
}
String OS_LinuxBSD::get_processor_name() const {
FileAccessRef f = FileAccess::open("/proc/cpuinfo", FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, "", String("Couldn't open `/proc/cpuinfo` to get the CPU model name. Returning an empty string."));
while (!f->eof_reached()) {
const String line = f->get_line();
if (line.find("model name") != -1) {
return line.split(":")[1].strip_edges();
}
}
ERR_FAIL_V_MSG("", String("Couldn't get the CPU model name from `/proc/cpuinfo`. Returning an empty string."));
}
void OS_LinuxBSD::finalize() {
if (main_loop) {
memdelete(main_loop);