realpath()

returns the canonical version of an absolute path name 

Function


SYNOPSIS

#include <sys/param.h>

#include <stdlib.h>

char * realpath(const char *pathname, char *resolved_path);


DESCRIPTION

The realpath() function takes a specified path name, pathname and resolves all symbolic links, extra slashes (/), and references to /./ and /../. The resulting absolute path name is placed in the memory location pointed to by the resolved_path argument.


PARAMETERS

pathname 

Points to the path name that you want resolved to an absolute form. This may be either a relative or absolute path name. All but the final component of this path name must exist when you call realpath().

resolved_path 

Points to the location where the canonical version of pathname is to be placed. If this argument is NULL, the return value is malloc()ed. When resolved_path is non-NULL, it must point to a buffer capable of storing at least PATH_MAX characters (that is, large enough to store a fully resolved path name).


RETURN VALUES

When successful, realpath() returns resolved_path. When an error occurs, realpath() returns a null pointer, setsresolved_path to the path name that caused the error, and sets errno to one of the following values:

EACCES 

A parent directory cannot be read to get its name.

Read or search permission was denied for a component of the path name.

EFAULT 

pathname points outside the allocated address space of the process.

EINTR 

A signal interrupted the call.

EINVAL 

The pathname parameter contains an invalid character.

EIO 

An I/O error occurred while reading from or writing to the file system.

ELOOP 

Traversal through readlink()s exceeds MAXSYMLINKS which is defined as 8 in sys/param.h.

ENAMETOOLONG 

The pathname parameter exceeds PATH_MAX in length or a pathname component is longer than NAME_MAX while _POSIX_NO_TRUNC is in effect.

ENOENT 

The pathname parameter is an empty string.

ENOTDIR 

A component of the pathname parameter is not a directory.

ENOMEM 

Insufficient memory exists to allocate a buffer to hold the path name.


CONFORMANCE

BSD 4.4.


MULTITHREAD SAFETY LEVEL

Async Signal-Safe.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
getcwd(), readlink()


PTC MKS Toolkit 10.3 Documentation Build 39.