Added src/mkdir.c, src/rm.c, some tips for commiters and close file descriptor in src/touch.c

This commit is contained in:
qorg11 2020-06-02 01:56:22 +02:00
parent cb17679d67
commit 62ecbded92
Signed by: qorg11
GPG Key ID: 343FC20A4ACA62B9
5 changed files with 58 additions and 0 deletions

View File

@ -70,3 +70,12 @@ chmod("whatever",420)
chmod("whatever",420) /* 420 is 644 in decimal
~~~
## For commiters
Commiters may or may not be anonymous. If you want to be
anonymous. Set whatever you want to git name and git email.
If you don't want to be anonymous, you should sign your commits using
gpg. See
[this]https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/()

3
TODO Normal file
View File

@ -0,0 +1,3 @@
* The rest of programs.
* Manuals
* flags for the programs

22
src/mkdir.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <sys/stat.h>
int
main(int argc, char *argv[])
{
if (argc == 1)
{
fprintf(stderr,"specify path(s) to make\n");
return 1;
}
for(int i = 1; i<argc;i++)
{
int fd = mkdir(argv[i],420);
if(fd == -1)
{
fprintf(stderr,"Error creating dir %s\n",argv[i]);
return 1;
}
}
return 0;
}

22
src/rm.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
int
main(int argc, char *argv[])
{
if (argc == 1)
{
printf("Specify files to remove.\n");
return 1;
}
for(int i = 1; i<argc;i++)
{
int fd = remove(argv[i]);
if(fd == -1)
{
fprintf(stderr,"Error removing file: %s\n",argv[i]);
}
}
return 0;
}

View File

@ -1,6 +1,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int
main(int argc, char *argv[])
@ -19,5 +20,6 @@ main(int argc, char *argv[])
return 1;
}
chmod(argv[1],420); /* 644 in decimal */
close(fd);
return 0;
}