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; }