Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

realpath - output real file name/pathname

&pagelevel(4)&pagelevel

Syntax

#include <stdlib.h>

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

Description

From the pathname specified in file_name, realpath() derives an absolute pathname in which all symbolic links and references to ’.’ and ’..’ are resolved. This “real” pathname is stored in resolved_name up to {MAX_PATH} bytes.

Both relative and absolute pathnames can be processed. With absolute pathnames and relative pathnames whose resolved name cannot be printed out relatively (e.g. ../../reldir), the resolved absolute name is returned. For the other relative pathnames the resolved relative name is returned. resolved_name must be large enough to incorporate the resolved pathname.

Return val.

Pointer to resolved_name



if successful.

 

Null pointer

otherwise. errno is set to indicate the error.

Errors

realpath() will fail if: 

 

EACCES

Read or search permission is denied for a component of file_name.

 

EINVAL

The file_name or resolved_name argument is a null pointer.

 

EIO

An I/O error occurred during reading from the file system.

 

ENAMETOOLONG 



The length of the file_name argument exceeds {PATH_MAX}, or the length of a component of file_name exceeds {NAME_MAX}.

In resolving a symbolic link, a interim result was produced whose length exceeds {PATH_MAX}.

 

ENOENT

A component of the path prefix does not exist or file_name is an empty string.

 

ENOTDIR

A component of the path prefix is not a directory.

 

ENOMEM

There is no longer enough memory available.

Notes

realpath() handles null-terminated strings.

You should have execution permission for all directories in the given and resolved path.

In certain circumstances realpath() may not return to the current directory if an error occurs.

See also

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