分类: LINUX
2013-04-28 18:13:23
/** mkdir1.c ** ------------------------------------------------------------ A version of mkdir that supports the -p option is: sol04.15.c. This program allows multiple names on the command line. ** ------------------------------------------------------------ ** ** * A version of mkdir that supports the -p option * * usage: mkdir1 [-p] dir1 [dir2 ..] * * exits with code 1 if any error */ #include#include #include #include #include #include #include #include #include #define MODE 0755 /* will be modified by umask */ int main(int ac, char *av[]) { int p_flag = 0; int rv = 0; p_flag = check_args(ac,av); while(rv == 0 && --ac) if ( **++av != '-' ) if ( do_mkdir(*av, p_flag) == -1 ) rv = 1; return rv; } /* * check_args(int ac, char *av[]) * returns a boolean value indicating if a -p has been seen */ int check_args(int ac, char *av[]) { int i; for(i=1; i