Whatever this does lmao

This commit is contained in:
qorg11 2020-08-23 18:48:44 +02:00
parent 20eb8d53d4
commit 016c4f6a39
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
1 changed files with 36 additions and 0 deletions

36
src/du.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <getopt.h>
int
main(int argc, char *argv[])
{
int c;
int human_readable = 0;
struct stat file_data;
while((c = getopt(argc, argv, "h")) != -1)
{
switch(c)
{
case 'h': human_readable = 1; break;
}
}
if(argc == optind)
{
printf("no!\n");
return 1;
}
for(int i = optind; i < argc; i++)
{
stat(argv[i], &file_data);
if(human_readable)
printf("%li\t %s",file_data.st_size * 1024, argv[i]);
else
printf("%li\t %s",file_data.st_size, argv[i]);
puts("");
}
return 0;
}