Rev 8827 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8827 | Rev 9173 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | extern int (*mkdir)(char*); |
|
Line 1... | Line 2... | ||
1 | int cmd_mkdir(char dir[]) { |
2 | |
2 | char temp[FILENAME_MAX]; |
- | |
3 | kol_struct70 k70; |
- | |
4 | unsigned result; |
3 | int cmd_mkdir(char dir[]) { |
5 | - | ||
6 | if (NULL == dir) { |
4 | unsigned dir_len = strlen(dir); |
7 | printf(CMD_MKDIR_USAGE); |
5 | if(!dir_len){ |
8 | return TRUE; |
6 | printf(CMD_MKDIR_USAGE); |
9 | } |
7 | return TRUE; |
Line -... | Line 8... | ||
- | 8 | } |
|
- | 9 | ||
10 | 10 | char *temp = malloc(dir_len+3); |
|
- | 11 | char *dir_path = strdup(dir); |
|
11 | if ( 0 == strcmp(dir, ".") || ( 0 == strcmp(dir, "..") ) || ( 0 == strcmp(cur_dir, "/")) ) { |
12 | ksys_bdfe_t *bdfe = malloc(sizeof(ksys_bdfe_t)); |
12 | return FALSE; |
13 | if(!dir_path || !temp || !bdfe){ |
Line 13... | Line -... | ||
13 | } |
- | |
14 | - | ||
15 | k70.p00 = 9; |
- | |
16 | k70.p04 = 0; |
- | |
17 | //k70.p08 = 0; |
- | |
18 | k70.p12 = 0; |
- | |
19 | k70.p16 = 0; |
- | |
20 | k70.p20 = 0; |
14 | return FALSE; |
21 | 15 | } |
|
22 | if ( '/' == dir[0]) |
16 | |
23 | k70.p21 = dir; |
- | |
24 | else { |
- | |
25 | strcpy(temp, cur_dir); |
- | |
26 | if (temp[strlen(temp)-1] != '/') |
17 | if(dir[0]=='/' || dir[0]=='\\'){ |
27 | strcat(temp, "/"); // add slash |
- | |
28 | strcat(temp, dir); |
18 | temp[0]='\0'; |
Line 29... | Line 19... | ||
29 | k70.p21 = temp; |
19 | }else{ |
Line 30... | Line 20... | ||
30 | } |
20 | strcpy(temp,"."); |
- | 21 | } |
|
- | 22 | ||
- | 23 | char *pch = strtok(dir_path,"\\/"); |
|
- | 24 | ||
- | 25 | while (pch != NULL){ |
|
- | 26 | strcat(temp, "/"); |
|
- | 27 | strcat(temp, pch); |
|
- | 28 | if(_ksys_file_get_info(temp, bdfe)){ |
|
- | 29 | if(mkdir(temp)){ |
|
- | 30 | printf("\033[0;31;40m FAIL %s\n", temp); |
|
- | 31 | }else { |
|
- | 32 | printf("\033[0;32;40m OK %s\n", temp); |
|
- | 33 | } |
|
- | 34 | }else{ |
|
- | 35 | printf("\033[0;33;40m EXIST %s\n", temp); |
|
- | 36 | } |
|
- | 37 | pch = strtok(NULL, "\\/"); |
|
31 | 38 | } |
|
32 | result = kol_file_70(&k70); |
- | |
33 | - | ||
34 | if (0 == result) |
- | |
35 | return TRUE; |
39 | printf("\033[0m"); |
36 | else |
- |