From a9b9937a3d85a9182b7520286323aa67204a4d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 10 Jul 2009 13:31:02 +0000 Subject: [PATCH] * Fixed remove(): it should behave like rmdir() for directories. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31500 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/stdio/remove.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/system/libroot/posix/stdio/remove.c b/src/system/libroot/posix/stdio/remove.c index fbb7a5c16b..e8120650af 100644 --- a/src/system/libroot/posix/stdio/remove.c +++ b/src/system/libroot/posix/stdio/remove.c @@ -1,19 +1,25 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ +/* + * Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + */ #include -#include + #include +#include + int -remove(const char *path) +remove(const char* path) { + // TODO: find a better way that does not require two syscalls for directories int status = _kern_unlink(-1, path); - if (status < B_OK) { + if (status == B_IS_A_DIRECTORY) + status = _kern_remove_dir(-1, path); + + if (status != B_OK) { errno = status; return -1; }