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 <errno_private.h> 13 #include <syscalls.h> 14 15 16 char* 17 realpath(const char* path, char* resolved) 18 { 19 status_t status = _kern_normalize_path(path, true, resolved); 20 if (status != B_OK) { 21 __set_errno(status); 22 return NULL; 23 } 24 25 // The path must actually exist, not just its parent directories 26 struct stat stat; 27 if (lstat(resolved, &stat) != 0) 28 return NULL; 29 30 return resolved; 31 } 32