Mercurial > hg > octave-kai > gnulib-hg
annotate lib/rmdir.c @ 10690:01f3623813da
Split winsock.c into many smaller files.
* lib/close.c: Add _gl_close_fd_maybe_socket from winsock.c.
* lib/accept.c: New file, based on winsock.c.
* lib/bind.c: New file, based on winsock.c.
* lib/connect.c: New file, based on winsock.c.
* lib/getpeername.c: New file, based on winsock.c.
* lib/getsockname.c: New file, based on winsock.c.
* lib/getsockopt.c: New file, based on winsock.c.
* lib/ioctl.c: New file, based on winsock.c.
* lib/listen.c: New file, based on winsock.c.
* lib/recv.c: New file, based on winsock.c.
* lib/recvfrom.c: New file, based on winsock.c.
* lib/send.c: New file, based on winsock.c.
* lib/sendto.c: New file, based on winsock.c.
* lib/setsockopt.c: New file, based on winsock.c.
* lib/shutdown.c: New file, based on winsock.c.
* lib/socket.c: New file, based on winsock.c.
* lib/w32sock.h: New file, based on winsock.c.
* lib/winsock.c: Remove file.
* modules/accept: Likewise.
* modules/bind: Likewise.
* modules/connect: Likewise.
* modules/getpeername: Likewise.
* modules/getsockname: Likewise.
* modules/getsockopt: Likewise.
* modules/ioctl: Likewise.
* modules/listen: Likewise.
* modules/recv: Likewise.
* modules/recvfrom: Likewise.
* modules/send: Likewise.
* modules/sendto: Likewise.
* modules/setsockopt: Likewise.
* modules/shutdown: Likewise.
* modules/socket: Use socket.c instead of winsock.c.
* modules/sys_socket: Remove (unneeded?) dependency on winsock.c.
* doc/posix-functions/accept.texi: Doc fix.
* doc/posix-functions/bind.texi: Doc fix.
* doc/posix-functions/close.texi: Doc fix.
* doc/posix-functions/connect.texi: Doc fix.
* doc/posix-functions/getpeername.texi: Doc fix.
* doc/posix-functions/getsockname.texi: Doc fix.
* doc/posix-functions/getsockopt.texi: Doc fix.
* doc/posix-functions/ioctl.texi: Doc fix.
* doc/posix-functions/listen.texi: Doc fix.
* doc/posix-functions/recv.texi: Doc fix.
* doc/posix-functions/recvfrom.texi: Doc fix.
* doc/posix-functions/send.texi: Doc fix.
* doc/posix-functions/sendto.texi: Doc fix.
* doc/posix-functions/setsockopt.texi: Doc fix.
* doc/posix-functions/shutdown.texi: Doc fix.
* doc/posix-functions/socket.texi: Doc fix.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Tue, 21 Oct 2008 12:17:19 +0200 |
parents | bbbbbf4cd1c5 |
children | 767d867147de |
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 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7581
diff
changeset
|
6 This program is free software: you can redistribute it and/or modify |
315 | 7 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7581
diff
changeset
|
8 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7581
diff
changeset
|
9 (at your option) any later version. |
315 | 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 | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7581
diff
changeset
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
315 | 18 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
19 #include <config.h> |
315 | 20 |
21 #include <sys/types.h> | |
22 #include <sys/stat.h> | |
23 #include <errno.h> | |
24 | |
25 /* rmdir adapted from GNU tar. */ | |
26 | |
5907 | 27 /* Remove directory DIR. |
315 | 28 Return 0 if successful, -1 if not. */ |
29 | |
30 int | |
5907 | 31 rmdir (char const *dir) |
315 | 32 { |
1768
d12253dc9dbb
(rmdir): Use pid_t instead of int; check status
Jim Meyering <jim@meyering.net>
parents:
775
diff
changeset
|
33 pid_t cpid; |
d12253dc9dbb
(rmdir): Use pid_t instead of int; check status
Jim Meyering <jim@meyering.net>
parents:
775
diff
changeset
|
34 int status; |
315 | 35 struct stat statbuf; |
36 | |
5907 | 37 if (stat (dir, &statbuf) != 0) |
315 | 38 return -1; /* errno already set */ |
39 | |
40 if (!S_ISDIR (statbuf.st_mode)) | |
41 { | |
42 errno = ENOTDIR; | |
43 return -1; | |
44 } | |
45 | |
46 cpid = fork (); | |
47 switch (cpid) | |
48 { | |
49 case -1: /* cannot fork */ | |
50 return -1; /* errno already set */ | |
51 | |
52 case 0: /* child process */ | |
5907 | 53 execl ("/bin/rmdir", "rmdir", dir, (char *) 0); |
315 | 54 _exit (1); |
55 | |
56 default: /* parent process */ | |
57 | |
58 /* Wait for kid to finish. */ | |
59 | |
60 while (wait (&status) != cpid) | |
61 /* Do nothing. */ ; | |
62 | |
1768
d12253dc9dbb
(rmdir): Use pid_t instead of int; check status
Jim Meyering <jim@meyering.net>
parents:
775
diff
changeset
|
63 if (status) |
315 | 64 { |
65 | |
66 /* /bin/rmdir failed. */ | |
67 | |
68 errno = EIO; | |
69 return -1; | |
70 } | |
71 return 0; | |
72 } | |
73 } |