Rev 3277 | Rev 3294 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3277 | Rev 3286 | ||
---|---|---|---|
1 | /* Automatically generated by mknewcmd on Mon Aug 11 00:06:46 PHT 2008 |
1 | /* Automatically generated by mknewcmd on Mon Aug 11 00:06:46 PHT 2008 |
2 | * This is machine generated output. The author of mknewcmd claims no |
2 | * This is machine generated output. The author of mknewcmd claims no |
3 | * copyright over the contents of this file. Where legally permitted, the |
3 | * copyright over the contents of this file. Where legally permitted, the |
4 | * contents herein are donated to the public domain. |
4 | * contents herein are donated to the public domain. |
5 | * |
5 | * |
6 | * You should apply any license and copyright that you wish to this file, |
6 | * You should apply any license and copyright that you wish to this file, |
7 | * replacing this header in its entirety. */ |
7 | * replacing this header in its entirety. */ |
8 | 8 | ||
9 | #include <stdio.h> |
9 | #include <stdio.h> |
10 | #include <stdlib.h> |
10 | #include <stdlib.h> |
- | 11 | #include <dirent.h> |
|
- | 12 | #include <fcntl.h> |
|
- | 13 | #include <sys/types.h> |
|
- | 14 | #include <sys/stat.h> |
|
- | 15 | ||
- | 16 | #include "config.h" |
|
- | 17 | #include "errors.h" |
|
11 | #include "entry.h" |
18 | #include "entry.h" |
12 | #include "mkdir.h" |
19 | #include "mkdir.h" |
13 | #include "cmds.h" |
20 | #include "cmds.h" |
14 | 21 | ||
15 | static char *cmdname = "mkdir"; |
22 | static char *cmdname = "mkdir"; |
16 | 23 | ||
17 | /* Dispays help for mkdir in various levels */ |
24 | /* Dispays help for mkdir in various levels */ |
18 | void * help_cmd_mkdir(unsigned int level) |
25 | void * help_cmd_mkdir(unsigned int level) |
19 | { |
26 | { |
- | 27 | if (level == HELP_SHORT) { |
|
20 | printf("This is the %s help for '%s'.\n", |
28 | printf("`%s' creates a new directory\n", cmdname); |
- | 29 | } else { |
|
- | 30 | help_cmd_mkdir(HELP_SHORT); |
|
21 | level ? EXT_HELP : SHORT_HELP, cmdname); |
31 | printf(" `%s' <directory>\n", cmdname); |
- | 32 | } |
|
- | 33 | ||
22 | return 0; |
34 | return CMD_VOID; |
23 | } |
35 | } |
24 | 36 | ||
25 | /* Main entry point for mkdir, accepts an array of arguments */ |
37 | /* Main entry point for mkdir, accepts an array of arguments */ |
26 | int * cmd_mkdir(char **argv) |
38 | int * cmd_mkdir(char **argv) |
27 | { |
39 | { |
28 | unsigned int argc; |
40 | unsigned int argc; |
29 | unsigned int i; |
41 | DIR *dirp; |
30 | 42 | ||
31 | /* Count the arguments */ |
43 | /* Count the arguments */ |
32 | for (argc = 0; argv[argc] != NULL; argc ++); |
44 | for (argc = 0; argv[argc] != NULL; argc ++); |
33 | 45 | ||
- | 46 | if (argc != 2) { |
|
34 | printf("%s %s\n", TEST_ANNOUNCE, cmdname); |
47 | printf("%s - too many arguments. Try `help %s extended'\n", |
35 | printf("%d arguments passed to %s", argc - 1, cmdname); |
48 | cmdname, cmdname); |
- | 49 | return CMD_FAILURE; |
|
- | 50 | } |
|
36 | 51 | ||
- | 52 | dirp = opendir(argv[1]); |
|
37 | if (argc < 2) { |
53 | if (dirp) { |
38 | printf("\n"); |
54 | closedir(dirp); |
- | 55 | cli_error(CL_EEXISTS, "Can not create directory %s", argv[1]); |
|
39 | return 0; |
56 | return CMD_FAILURE; |
40 | } |
57 | } |
41 | 58 | ||
42 | printf(":\n"); |
59 | if (mkdir(argv[1], 0) != 0) { |
43 | for (i = 1; i < argc; i++) |
60 | cli_error(CL_EFAIL, "Could not create %s", argv[1]); |
44 | printf("[%d] -> %s\n", i, argv[i]); |
61 | return CMD_FAILURE; |
- | 62 | } |
|
45 | 63 | ||
46 | return 0; |
64 | return CMD_SUCCESS; |
47 | } |
65 | } |
48 | 66 | ||
49 | 67 |