Mercurial > hg > toybox
comparison toys/posix/rmdir.c @ 653:2986aa63a021
Move commands into "posix", "lsb", and "other" menus/directories.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 25 Aug 2012 14:25:22 -0500 |
parents | toys/rmdir.c@75a69d5550a0 |
children | 786841fdb1e0 |
comparison
equal
deleted
inserted
replaced
652:2d7c56913fda | 653:2986aa63a021 |
---|---|
1 /* vi: set sw=4 ts=4: | |
2 * | |
3 * rmdir.c - remove directory/path | |
4 * | |
5 * Copyright 2008 Rob Landley <rob@landley.net> | |
6 * | |
7 * See http://opengroup.org/onlinepubs/9699919799/utilities/rmdir.html | |
8 | |
9 USE_RMDIR(NEWTOY(rmdir, "<1p", TOYFLAG_BIN)) | |
10 | |
11 config RMDIR | |
12 bool "rmdir" | |
13 default y | |
14 help | |
15 usage: rmdir [-p] [dirname...] | |
16 Remove one or more directories. | |
17 | |
18 -p Remove path. | |
19 */ | |
20 | |
21 #include "toys.h" | |
22 | |
23 static void do_rmdir(char *name) | |
24 { | |
25 for (;;) { | |
26 char *temp; | |
27 | |
28 if (rmdir(name)) { | |
29 perror_msg("%s",name); | |
30 return; | |
31 } | |
32 if (!toys.optflags) return; | |
33 if (!(temp=strrchr(name,'/'))) return; | |
34 *temp=0; | |
35 } | |
36 } | |
37 | |
38 void rmdir_main(void) | |
39 { | |
40 char **s; | |
41 | |
42 for (s=toys.optargs; *s; s++) do_rmdir(*s); | |
43 } |