summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/remove.c
diff options
context:
space:
mode:
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 cca7cb6..3518b68 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));
}
OpenPOWER on IntegriCloud