Resolves path names.
Standard C Library (libc.a)
#include <stdlib.h>
char *realpath (const char *file_name, char *resolved_name)
The realpath subroutine performs filename expansion and path name resolution in file_name and stores it in resolved_name.
The realpath subroutine can handle both relative and absolute path names. For both absolute and relative path names, the realpath subroutine returns the resolved absolute path name.
The character pointed to by resolved_name must be big enough to contain the fully resolved path name. The value of PATH_MAX (defined in limits.h header file may be used as an appropriate array size.
On successful completion, the realpath subroutine returns a pointer to the resolved name. Otherwise, it returns a null pointer, and sets errno to indicate the error. If the realpath subroutine encounters an error, the contents of resolved_name are undefined.
Under the following conditions, the realpath subroutine fails and sets errno to:
Item | Description |
---|---|
EACCES | Read or search permission was denied for a component of the path name. |
EINVAL | File_name or resolved_name is a null pointer. |
ELOOP | Too many symbolic links are encountered in translating file_name. |
ENAMETOOLONG | The length of file_name or resolved_name exceeds PATH_MAX or a path name component is longer than NAME_MAX. |
ENOENT | The file_name parameter does not exist or points to an empty string. |
ENOTDIR | A component of the file_name prefix is not a directory. |
The realpath subroutine may fail if:
Item | Description |
---|---|
ENOMEM | Insufficient storage space is available. |