* 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

View File

@ -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 <stdio.h>
#include <syscalls.h>
#include <errno.h>
#include <syscalls.h>
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;
}