mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
refactored project structure
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#include "fastfetch.h"
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
void ffPrintDisk(FFstate* state)
|
||||
{
|
||||
struct statvfs fs;
|
||||
int ret = statvfs("/", &fs);
|
||||
if(ret != 0)
|
||||
{
|
||||
ffPrintError(state, "Disk (/)", "statvfs(\"/\", &fs) != 0");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t GB = (1024 * 1024) * 1024;
|
||||
|
||||
const uint32_t total = (fs.f_blocks * fs.f_frsize) / GB;
|
||||
const uint32_t available = (fs.f_bfree * fs.f_frsize) / GB;
|
||||
const uint32_t used = total - available;
|
||||
const uint32_t percentage = (used / (double) total) * 100.0;
|
||||
|
||||
|
||||
ffPrintLogoAndKey(state, "Disk (/)");
|
||||
printf("%uGB / %uGB (%u%%)\n", used, total, percentage);
|
||||
}
|
||||
Reference in New Issue
Block a user