mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
refactored project structure
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void ffPrintHost(FFstate* state)
|
||||
{
|
||||
if(ffPrintCachedValue(state, "Host"))
|
||||
return;
|
||||
|
||||
char host[1024];
|
||||
|
||||
FILE* nameFile = fopen("/sys/devices/virtual/dmi/id/product_name", "r");
|
||||
if(nameFile == NULL)
|
||||
{
|
||||
ffPrintError(state, "Host", "fopen(\"/sys/devices/virtual/dmi/id/product_name\", \"r\") == NULL");
|
||||
return;
|
||||
}
|
||||
if(fscanf(nameFile, "%[^\n]", host) != 1)
|
||||
{
|
||||
ffPrintError(state, "Host", "fscanf(nameFile, \"%[^\\n]\", name) != 1");
|
||||
return;
|
||||
}
|
||||
fclose(nameFile);
|
||||
|
||||
FILE* versionFile = fopen("/sys/devices/virtual/dmi/id/product_version", "r");
|
||||
if(versionFile != NULL)
|
||||
{
|
||||
ssize_t len = strlen(host);
|
||||
host[len] = ' ';
|
||||
if(fscanf(versionFile, "%[^\n]", host + len + 1) == 0); //fail silently, if reading of version fails, just show now version
|
||||
fclose(versionFile);
|
||||
}
|
||||
|
||||
ffPrintAndSaveCachedValue(state, "Host", host);
|
||||
}
|
||||
Reference in New Issue
Block a user