annotate toys/posix/rmdir.c @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <rob@landley.net>
date Tue, 13 Nov 2012 17:14:08 -0600
parents 2986aa63a021
children 3d7526f6115b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
1 /* rmdir.c - remove directory/path
290
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 * Copyright 2008 Rob Landley <rob@landley.net>
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 * 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
6
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 USE_RMDIR(NEWTOY(rmdir, "<1p", TOYFLAG_BIN))
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 config RMDIR
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
10 bool "rmdir"
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
11 default y
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
12 help
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
13 usage: rmdir [-p] [dirname...]
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
14 Remove one or more directories.
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
16 -p Remove path.
290
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
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 #include "toys.h"
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 static void do_rmdir(char *name)
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
22 {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
23 for (;;) {
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
24 char *temp;
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
25
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
26 if (rmdir(name)) {
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
27 perror_msg("%s",name);
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
28 return;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
29 }
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
30 if (!toys.optflags) return;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
31 if (!(temp=strrchr(name,'/'))) return;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
32 *temp=0;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
33 }
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
34 }
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 void rmdir_main(void)
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
37 {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
38 char **s;
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
39
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
40 for (s=toys.optargs; *s; s++) do_rmdir(*s);
290
d37e2de3a9f3 Add rmdir and test for it.
Rob Landley <rob@landley.net>
parents:
diff changeset
41 }