agetcwd(3)

NAME

agetcwd \- get current working directory

SYNOPSIS

#include <pathfns.h>

char *agetcwd(void);

DESCRIPTION

This function determines the path of the current working directory and returns it in a buffer allocated by malloc(3), with a null terminator.

RETURN VALUES

If the return value is not a null pointer then the operation succeeded and the return value is a pointer to the newly created string.

If the return value is a null pointer then the operation failed and errno is set appropriately:

ENOENT

The current directory has no path name. This can happen (for example) if a directory is removed while it is the current working directory of some process.

ENOMEM

Insufficient memory (provided the local malloc sets errno).

EACCESS

Permission denied.

EMFILE

Too many file descriptor in use by this process.

ENFILE

Too many file descriptor open on the system.

ENAMETOOLONG

Filename too long.

The only error value set directly by this function is ENOENT; all the rest are propagated from calls to other functions.

NOTES

getcwd(3) performs a similar operation to this function, but limits the size of the answer to a user-supplied buffer size, which is not acceptable.

Some C libraries provide better interfaces, it is up to the individual programmer to decide whether to use them or to use this function.

SEE ALSO

getcwd(3), malloc(3), free(3)