From fafff148e10ab137d6494753a47905a2262a870d Mon Sep 17 00:00:00 2001 From: Thorsten Lockert Date: Mon, 28 Oct 1996 04:55:26 +0000 Subject: remove(3) should be able to remove empty directories --- lib/libc/stdio/remove.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/libc') 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 #include +#include +#include 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)); } -- cgit v1.2.3