commit ff4f7c12663ae9e16ea1449f345aae9a6c9016a7
parent 36b73021b69f8cfca18286f083091df5d5206b69
Author: qorg11 <qorg@vxempire.xyz>
Date: Mon, 1 Jun 2020 22:02:05 +0200
Added touch
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/src/touch.c b/src/touch.c
@@ -0,0 +1,23 @@
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/stat.h>
+
+int
+main(int argc, char *argv[])
+{
+ if(argc <=1)
+ {
+ fprintf(stderr,"Give a file\n");
+ return 1;
+ }
+
+ int fd = open(argv[1],O_RDWR|O_CREAT);
+
+ if(fd == -1)
+ {
+ fprintf(stderr,"Error creating file\n");
+ return 1;
+ }
+ chmod(argv[1],420); /* 644 in decimal */
+ return 0;
+}