-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkdir.c
More file actions
45 lines (43 loc) · 746 Bytes
/
Copy pathmkdir.c
File metadata and controls
45 lines (43 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if(!strcmp(argv[1],"-m")){
char* mode;
mode=(char*)malloc(sizeof(char*)*100);
mode=argv[2];
char* name=argv[3];
int ret;
ret=mkdir(name,0777);
if(ret==-1){
perror("Error");
}
int i;
i= strtol(mode, 0, 8);
chmod(name,i);
}
else if(!strcmp(argv[1],"-v")){
char* name=argv[2];
int ret;
ret=mkdir(name,0777);
if(ret==0){
printf("mkdir: created directory '%s'\n",argv[2]);}
if(ret==-1){
perror("Error");
}
}
else{
char* name=argv[1];
int ret;
ret=mkdir(name,0777);
if(ret==-1){
perror("Error");
}
}
return 0;
}