[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

realpath Subroutine

Purpose

Resolves path names.

Library

Standard C Library (libc.a)

Syntax

#include <stdlib.h>

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

Description

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.

Return Values

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.

Error Codes

Under the following conditions, the realpath subroutine fails and sets errno to:

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:

ENOMEM Insufficient storage space is available.

Related Information

The getcwd or sysconf (sysconf Subroutine) subroutine.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]