Added touch

This commit is contained in:
qorg11 2020-06-01 22:02:05 +02:00
parent 36b73021b6
commit ff4f7c1266
Signed by: qorg11
GPG Key ID: 343FC20A4ACA62B9
1 changed files with 23 additions and 0 deletions

23
src/touch.c Normal file
View File

@ -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;
}