Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/rmdir.c @ 7581:45c727466eb8
Move stat.h-substitute stuff from lib/stat-macros.h to lib/stat_.h.
stat-macros.h is now for our own macros, whereas stat_h is for
macros in the <sys/stat.h> name space.
* lib/stat-macros.h: Remove copyright notice, as this file is now tiny.
(STAT_MACROS_H): Remove.
(S_IFMT, S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISLNK, S_ISNAM):
(S_ISMPB, S_ISMPC, S_ISNWK, S_ISREG, S_ISSOCK, S_ISDOOR, S_ISPORT):
(S_TYPEISMQ, S_TYPEISTMO, S_TYPEISSEM, S_TYPEISSHM, S_ISCTG, S_ISOFD):
(S_ISOFL, S_ISWHT, S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IRGRP):
(S_IROTH, S_IWUSR, S_IWGRP, S_IWOTH, S_IXUSR, S_IXGRP, S_IXOTH):
(S_IRWXU, S_IRWXG, S_IRWXO, S_IXUGO, S_IRWXUGO):
Move these macros to ...
* lib/stat_.h: here. Don't include stat-macros.h.
* lib/canonicalize.c: Don't include stat-macros.h.
* lib/chown.c: Likewise.
* lib/euidaccess.c: Likewise.
* lib/file-type.c: Likewise.
* lib/filemode.c: Likewise.
* lib/glob.c: Likewise.
* lib/isapipe.c: Likewise.
* lib/lchown.c: Likewise.
* lib/lstat.c: Likewise.
* lib/mkdir-p.c: Likewise.
* lib/rmdir.c: Likewise.
* m4/lchown.m4 (gl_FUNC_LCHOWN): Don't require gl_STAT_MACROS.
* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Don't check for io.h
unless mkdir isn't declared, to speed up 'configure'.
Always create sys/stat.h, since it's unlikely any real sys/stat.h
would define all the S_* symbols.
* modules/canonicalize (Depends-on):
Depend on sys_stat, not stat-macros.
* modules/chown: Likewise.
* modules/euidaccess: Likewise.
* modules/filemode: Likewise.
* modules/file-type: Likewise.
* modules/glob: Likewise.
* modules/isapipe: Likewise.
* modules/lchown: Likewise.
* modules/lstat: Likewise.
* modules/mkancesdirs: Likewise.
* modules/rmdir: Likewise.
* modules/mkdir-p (Depends-on): Also depend on sys_stat.
* modules/modechange: Likewise.
* modules/stat-macros (Files): Remove m4/stat-macros.m4.
(configure.ac): Remove gl_STAT_MACROS.
* modules/sys_stat (Depends-on): Remove stat-macros.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 27 Oct 2006 20:46:43 +0000 |
parents | 8a1a9361108c |
children | bbbbbf4cd1c5 |
rev | line source |
---|---|
775 | 1 /* BSD compatible remove directory function for System V |
4665 | 2 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
3 Copyright (C) 1988, 1990, 1999, 2003, 2004, 2005, 2006 Free |
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
4 Software Foundation, Inc. |
315 | 5 |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2, or (at your option) | |
9 any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
650
b4ef1c1a0171
update FSF address in copyright
Jim Meyering <jim@meyering.net>
parents:
439
diff
changeset
|
17 along with this program; if not, write to the Free Software Foundation, |
5848
a48fb0e98c8c
*** empty log message ***
Paul Eggert <eggert@cs.ucla.edu>
parents:
5159
diff
changeset
|
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
315 | 19 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
20 #include <config.h> |
315 | 21 |
22 #include <sys/types.h> | |
23 #include <sys/stat.h> | |
24 #include <errno.h> | |
25 | |
26 /* rmdir adapted from GNU tar. */ | |
27 | |
5907 | 28 /* Remove directory DIR. |
315 | 29 Return 0 if successful, -1 if not. */ |
30 | |
31 int | |
5907 | 32 rmdir (char const *dir) |
315 | 33 { |
1768
d12253dc9dbb
(rmdir): Use pid_t instead of int; check status
Jim Meyering <jim@meyering.net>
parents:
775
diff
changeset
|
34 pid_t cpid; |
d12253dc9dbb
(rmdir): Use pid_t instead of int; check status
Jim Meyering <jim@meyering.net>
parents:
775
diff
changeset
|
35 int status; |
315 | 36 struct stat statbuf; |
37 | |
5907 | 38 if (stat (dir, &statbuf) != 0) |
315 | 39 return -1; /* errno already set */ |
40 | |
41 if (!S_ISDIR (statbuf.st_mode)) | |
42 { | |
43 errno = ENOTDIR; | |
44 return -1; | |
45 } | |
46 | |
47 cpid = fork (); | |
48 switch (cpid) | |
49 { | |
50 case -1: /* cannot fork */ | |
51 return -1; /* errno already set */ | |
52 | |
53 case 0: /* child process */ | |
5907 | 54 execl ("/bin/rmdir", "rmdir", dir, (char *) 0); |
315 | 55 _exit (1); |
56 | |
57 default: /* parent process */ | |
58 | |
59 /* Wait for kid to finish. */ | |
60 | |
61 while (wait (&status) != cpid) | |
62 /* Do nothing. */ ; | |
63 | |
1768
d12253dc9dbb
(rmdir): Use pid_t instead of int; check status
Jim Meyering <jim@meyering.net>
parents:
775
diff
changeset
|
64 if (status) |
315 | 65 { |
66 | |
67 /* /bin/rmdir failed. */ | |
68 | |
69 errno = EIO; | |
70 return -1; | |
71 } | |
72 return 0; | |
73 } | |
74 } |