k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 016c4f6a3954cba99e93cc92d928b49d0c5d3af4
parent 20eb8d53d4ef211f125d2793c0202a2842f31e04
Author: qorg11 <qorg@vxempire.xyz>
Date:   Sun, 23 Aug 2020 18:48:44 +0200

Whatever this does lmao

Diffstat:
Asrc/du.c | 36++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/du.c b/src/du.c @@ -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; +}