OS (Linux): detect detailed debian version

Ref: https://github.com/dylanaraps/neofetch/issues/2381
This commit is contained in:
李通洲
2023-09-24 21:49:39 +08:00
parent 6ccf8856b9
commit 3e768ddfd4
+12 -1
View File
@@ -1,6 +1,7 @@
#include "os.h"
#include "common/properties.h"
#include "common/parsing.h"
#include "common/io/io.h"
#include "util/stringUtils.h"
#include <string.h>
@@ -121,6 +122,14 @@ static void getUbuntuFlavour(FFOSResult* result)
}
}
static void getDebianVersion(FFOSResult* result)
{
FF_STRBUF_AUTO_DESTROY debianVersion = ffStrbufCreate();
ffAppendFileBuffer("/etc/debian_version", &debianVersion);
if (debianVersion.length)
ffStrbufSet(&result->version, &debianVersion);
}
static void detectOS(FFOSResult* os)
{
if(instance.config.osFile.length > 0)
@@ -169,6 +178,8 @@ void ffDetectOSImpl(FFOSResult* os)
detectOS(os);
if(ffStrbufIgnCaseCompS(&os->id, "ubuntu") == 0)
if(ffStrbufIgnCaseEqualS(&os->id, "ubuntu"))
getUbuntuFlavour(os);
else if(ffStrbufIgnCaseEqualS(&os->id, "debian"))
getDebianVersion(os);
}