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
This commit is contained in:
qorg11 2020-07-08 06:32:18 +02:00
parent b339661dc6
commit 755222ae67
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
1 changed files with 27 additions and 4 deletions

View File

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