The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


realpath - resolve a pathname


#include <stdlib.h>

char *realpath(const char *file_name, char *resolved_name);


The realpath() function derives, from the pathname pointed to by file_name, an absolute pathname that names the same file, whose resolution does not involve ".", "..", or symbolic links. The generated pathname is stored, up to a maximum of {PATH_MAX} bytes, in the buffer pointed to by resolved_name.


On successful completion, realpath() returns a pointer to the resolved name. Otherwise, realpath() returns a null pointer and sets errno to indicate the error, and the contents of the buffer pointed to by resolved_name are undefined.


The realpath() function will fail if:
Read or search permission was denied for a component of file_name.
Either the file_name or resolved_name argument is a null pointer.
An error occurred while reading from the file system.
Too many symbolic links were encountered in resolving path.
The file_name argument is longer than {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
A component of file_name does not name an existing file or file_name points to an empty string.
A component of the path prefix is not a directory.

The realpath() function may fail if:

Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.
Insufficient storage space is available.








getcwd(), sysconf(), <stdlib.h>.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]