1 /* 2 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <stdlib.h> 8 9 #include <errno.h> 10 #include <sys/stat.h> 11 12 #include <syscalls.h> 13 14 15 char* 16 realpath(const char* path, char* resolved) 17 { 18 status_t status = _kern_normalize_path(path, true, resolved); 19 if (status != B_OK) { 20 errno = status; 21 return NULL; 22 } 23 24 // The path must actually exist, not just its parent directories 25 struct stat stat; 26 if (lstat(resolved, &stat) != 0) 27 return NULL; 28 29 return resolved; 30 } 31