summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/remove.c
diff options
context:
space:
mode:
authorDavid Malone <dwmalone@FreeBSD.org>2000-08-28 15:45:42 +0000
committerDavid Malone <dwmalone@FreeBSD.org>2000-08-28 15:45:42 +0000
commitad8c1e6a094435bd3e1fe1167df68c58d86c749b (patch)
tree54e8d522ce3965e1863f1c1be5fde90945f02583 /lib/libc/stdio/remove.c
parent05efdfbfab879472a5c12aa47663c4b4a1b50390 (diff)
Notes
Diffstat (limited to 'lib/libc/stdio/remove.c')
-rw-r--r--lib/libc/stdio/remove.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c
index cca7cb627163..3518b68c7475 100644
--- a/lib/libc/stdio/remove.c
+++ b/lib/libc/stdio/remove.c
@@ -42,6 +42,8 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
@@ -49,5 +51,11 @@ int
remove(file)
const char *file;
{
+ struct stat sb;
+
+ if (lstat(file, &sb) < 0)
+ return (-1);
+ if (S_ISDIR(sb.st_mode))
+ return (rmdir(file));
return (unlink(file));
}