aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqorg11 <qorg@vxempire.xyz>2020-08-23 18:48:44 +0200
committerqorg11 <qorg@vxempire.xyz>2020-08-23 18:48:44 +0200
commit016c4f6a3954cba99e93cc92d928b49d0c5d3af4 (patch)
tree4b40beb6e6e21fea3754a8b323e31fe343b971ac
parent20eb8d53d4ef211f125d2793c0202a2842f31e04 (diff)
downloadk9core-016c4f6a3954cba99e93cc92d928b49d0c5d3af4.tar.gz
k9core-016c4f6a3954cba99e93cc92d928b49d0c5d3af4.zip
Whatever this does lmao
-rw-r--r--src/du.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/du.c b/src/du.c
new file mode 100644
index 0000000..cb773c6
--- /dev/null
+++ 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;
+}