k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 755222ae67ebdeb10ddf1ac8e7fbf3dca8d1946e
parent b339661dc6d2bce1cf5ce02fa868b7aa0ea111cb
Author: qorg11 <qorg@vxempire.xyz>
Date:   Wed,  8 Jul 2020 06:32:18 +0200

I just do a prototype of mkdir -p that does not work because it does
not work so is commented don't uncomment it unless you can fix it
thank you

Diffstat:
Msrc/mkdir.c | 31+++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/mkdir.c b/src/mkdir.c @@ -1,22 +1,45 @@ #include <stdio.h> #include <sys/stat.h> +#include <getopt.h> +#include <string.h> int main(int argc, char *argv[]) { + int c = getopt(argc, argv, "p"); if (argc == 1) { fprintf(stderr,"specify path(s) to make\n"); return 1; } + /* + if(c == 'p') + { + const char tok[2] = "/"; + char *token; + token = strtok(argv[2],tok); + char *directories = argv[2]; + printf("%s\n",directories); + while(token != NULL) + { + mkdir(token,511); + token = strtok(NULL,"/"); + printf("%s",token); + strcat(directories,"/"); + printf("%s",directories); + } + return 0; + } + */ 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; - } + { + fprintf(stderr,"Error creating dir %s\n",argv[i]); + return 1; + } } return 0; }