* 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
This commit is contained in:
Axel Dörfler
2009-07-10 13:31:02 +00:00
parent 3f7eb638dc
commit a9b9937a3d
+12 -6
View File
@@ -1,19 +1,25 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004-2009, Axel Dörfler, [email protected].
** Distributed under the terms of the Haiku License. * Distributed under the terms of the MIT License.
*/ */
#include <stdio.h> #include <stdio.h>
#include <syscalls.h>
#include <errno.h> #include <errno.h>
#include <syscalls.h>
int 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); 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; errno = status;
return -1; return -1;
} }