mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-12 14:31:00 +01:00
refactored project structure
This commit is contained in:
1 parent
558639086a
commit
b44ab16dd1
26 files changed
+219
-211
No files matched your search
@@ -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