1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#define FOR_rmdir
22#include "toys.h"
23
24static void do_rmdir(char *name)
25{
26 char *temp;
27
28 do {
29 if (rmdir(name)) {
30 if (!FLAG(ignore_fail_on_non_empty) || errno != ENOTEMPTY)
31 perror_msg_raw(name);
32 return;
33 }
34
35
36
37 if (!toys.optflags) return;
38 do {
39 if (!(temp = strrchr(name, '/'))) return;
40 *temp = 0;
41 } while (!temp[1]);
42 } while (*name);
43}
44
45void rmdir_main(void)
46{
47 char **s;
48
49 for (s=toys.optargs; *s; s++) do_rmdir(*s);
50}
51