#include <limits.h> #include <stdlib.h> char *realpath(const char *path, char *resolved_path);Feature Test Macro Requirements for glibc (see feature_test_macros (7)):
-
realpath():
- _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
Description
realpath() expands all symbolic links and resolves references to /./, /../ and extra '/' characters in the null-terminated string named by path to produce a canonicalized absolute pathname. The resulting pathname is stored as a null-terminated string, up to a maximum of PATH_MAX bytes, in the buffer pointed to by resolved_path. The resulting path will have no symbolic link, /./ or /../ components.
If resolved_path is specified as NULL, then realpath() uses malloc(3) to allocate a buffer of up to PATH_MAX bytes to hold the resolved pathname, and returns a pointer to this buffer. The caller should deallocate this buffer using free(3).
Return Value
If there is no error, realpath() returns a pointer to the resolved_path.
Otherwise, it returns a NULL pointer, the contents of the array resolved_path are undefined, and errno is set to indicate the error