* Replaced the broken BSD realpath() that is neither thread-safe nor POSIX

compliant with one that is both, and magnitudes faster at that, too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31498 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-07-10 12:27:05 +00:00
parent 71896c7386
commit 6de41102e5

View File

@ -0,0 +1,30 @@
/*
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*/
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
#include <syscalls.h>
char*
realpath(const char* path, char* resolved)
{
status_t status = _kern_normalize_path(path, true, resolved);
if (status != B_OK) {
errno = status;
return NULL;
}
// The path must actually exist, not just its parent directories
struct stat stat;
if (lstat(resolved, &stat) != 0)
return NULL;
return resolved;
}