mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-14 16:40:56 +00:00
- extended operating system information with os-release's pretty name
https://www.freedesktop.org/software/systemd/man/os-release.html
This commit is contained in:
parent
6089c34558
commit
1767fdfe7a
1 changed files with 43 additions and 4 deletions
|
@ -40,6 +40,7 @@
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#include "engineerrors.h"
|
#include "engineerrors.h"
|
||||||
|
@ -95,12 +96,50 @@ static int GetCrashInfo (char *buffer, char *end)
|
||||||
|
|
||||||
void I_DetectOS()
|
void I_DetectOS()
|
||||||
{
|
{
|
||||||
utsname unameInfo;
|
FString operatingSystem;
|
||||||
int unameRes = uname(&unameInfo);
|
|
||||||
if (unameRes != -1)
|
const char *paths[] = {"/etc/os-release", "/usr/lib/os-release"};
|
||||||
|
|
||||||
|
for (const char *path : paths)
|
||||||
{
|
{
|
||||||
Printf("OS: %s %s on %s\n", unameInfo.sysname, unameInfo.release, unameInfo.machine);
|
struct stat dummy;
|
||||||
|
|
||||||
|
if (stat(path, &dummy) != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
char cmdline[256];
|
||||||
|
snprintf(cmdline, sizeof cmdline, ". %s && echo ${PRETTY_NAME}", path);
|
||||||
|
|
||||||
|
FILE *proc = popen(cmdline, "r");
|
||||||
|
|
||||||
|
if (proc == nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
char distribution[256] = {};
|
||||||
|
fread(distribution, sizeof distribution - 1, 1, proc);
|
||||||
|
|
||||||
|
const size_t length = strlen(distribution);
|
||||||
|
|
||||||
|
if (length > 1)
|
||||||
|
{
|
||||||
|
distribution[length - 1] = '\0';
|
||||||
|
operatingSystem = distribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
pclose(proc);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utsname unameInfo;
|
||||||
|
|
||||||
|
if (uname(&unameInfo) == 0)
|
||||||
|
{
|
||||||
|
const char* const separator = operatingSystem.Len() > 0 ? ", " : "";
|
||||||
|
operatingSystem.AppendFormat("%s%s %s on %s", separator, unameInfo.sysname, unameInfo.release, unameInfo.machine);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operatingSystem.Len() > 0)
|
||||||
|
Printf("OS: %s\n", operatingSystem.GetChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_StartupJoysticks();
|
void I_StartupJoysticks();
|
||||||
|
|
Loading…
Reference in a new issue