realpath(S)
realpath --
returns the real file name
Syntax
cc ...-lc
#include <stdlib.h>
char *realpath (const char *file_name, char *resolved_name);
Description
realpath(S)
resolves all links, symbolic links, and references to ``.'' and ``..'' in
file_name and stores the path in
resolved_name.
It can handle both relative and absolute path names:
-
For absolute path names and the relative names whose resolved name
cannot be expressed relatively (for example,
../../reldir), it returns the
resolved absolute name.
-
For the other relative path names, it returns the
resolved relative name.
resolved_name must be big enough
(MAXPATHLEN) to contain the fully resolved path name.
realpath( )
operates on null-terminated strings.
You should have execute permission on all the directories
in the given and the resolved path.
If an error occurs,
realpath( )
may fail to return to the current directory.
Return values
If there is no error,
realpath( )
returns a pointer to the
resolved_name.
Otherwise it returns a null pointer
and places the name of the offending file in
resolved_name.
The global variable
errno
is set to indicate the error.
Diagnostics
If any of the following conditions occur, this function returns
-1 and sets errno to the corresponding value:
[EACCESS]-
The system denied you read or search permission for some part of
file_name.
[EINVAL]-
One of the arguments
file_name
or
resolved_name is a null pointer.
[EIO]-
The function encountered an I/O error while reading from the file system.
[ELOOP]-
The function found too many symbolic links while resolving the
path.
[ENAMETOOLONG]-
Either
file_name
or a component of the path name is longer than
PATH_MAX bytes.
[ENOENT]-
Either a component of
file_name
does not exist or
file_name
points to an empty string.
[ENOTDIR]-
Part of the pathname prefix is not a directory.
The following conditions might cause the function to fail:
[ENAMETOOLONG]-
Resolving a symbolic link in the pathname produced an
intermediate result that is longer than
PATH_MAX bytes.
[ENOMEM]-
There is not enough memory.
See also
getcwd(S)
Standards conformance
realpath(S)
is conformant with
X/Open CAE Specification, System Interfaces and Headers, Issue 4, Version 2.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003