annotate toys/rmdir.c @ 598:75a69d5550a0

Cosmetic tweak to command preamble.
author Rob Landley <rob@landley.net>
date Thu, 14 Jun 2012 00:01:14 -0500
parents d37e2de3a9f3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 /* vi: set sw=4 ts=4:
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
598
75a69d5550a0 Cosmetic tweak to command preamble.
Rob Landley <rob@landley.net>
parents: 290
diff changeset
3 * rmdir.c - remove directory/path
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 *
598
75a69d5550a0 Cosmetic tweak to command preamble.
Rob Landley <rob@landley.net>
parents: 290
diff changeset
5 * Copyright 2008 Rob Landley <rob@landley.net>
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 *
598
75a69d5550a0 Cosmetic tweak to command preamble.
Rob Landley <rob@landley.net>
parents: 290
diff changeset
7 * See http://opengroup.org/onlinepubs/9699919799/utilities/rmdir.html
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
8
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
9 USE_RMDIR(NEWTOY(rmdir, "<1p", TOYFLAG_BIN))
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
10
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
11 config RMDIR
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
12 bool "rmdir"
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 default y
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 help
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
15 usage: rmdir [-p] [dirname...]
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 Remove one or more directories.
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
17
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 -p Remove path.
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 */
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
20
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
21 #include "toys.h"
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
22
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 static void do_rmdir(char *name)
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 {
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 for (;;) {
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 char *temp;
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 if (rmdir(name)) {
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 perror_msg("%s",name);
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
30 return;
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
31 }
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
32 if (!toys.optflags) return;
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 if (!(temp=strrchr(name,'/'))) return;
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 *temp=0;
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 }
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 }
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
37
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 void rmdir_main(void)
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
39 {
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
40 char **s;
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
41
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
42 for (s=toys.optargs; *s; s++) do_rmdir(*s);
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
43 }