summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/remove.c
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1996-10-28 04:55:25 +0000
committertholo <tholo@openbsd.org>1996-10-28 04:55:25 +0000
commitdf1ce40c02f12ac03469418d9e8f33318bde6b7f (patch)
treeb4e47260e5d576e0f7b9a139b18f731174e88aa2 /lib/libc/stdio/remove.c
parentObsolete. (diff)
downloadwireguard-openbsd-df1ce40c02f12ac03469418d9e8f33318bde6b7f.tar.xz
wireguard-openbsd-df1ce40c02f12ac03469418d9e8f33318bde6b7f.zip
remove(3) should be able to remove empty directories
Diffstat (limited to 'lib/libc/stdio/remove.c')
-rw-r--r--lib/libc/stdio/remove.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c
index 189663d80e2..915149bc032 100644
--- a/lib/libc/stdio/remove.c
+++ b/lib/libc/stdio/remove.c
@@ -35,14 +35,21 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: remove.c,v 1.2 1996/08/19 08:33:01 tholo Exp $";
+static char rcsid[] = "$OpenBSD: remove.c,v 1.3 1996/10/28 04:55:25 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
-#include <unistd.h>
#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
remove(file)
const char *file;
{
+ struct stat st;
+
+ if (stat(file, &st) < 0)
+ return (-1);
+ if (S_ISDIR(st.st_mode))
+ return (rmdir(file));
return (unlink(file));
}