GETCWD

Section: Misc. Reference Manual Pages (3P)
Updated: August 1, 1992
Index Return to Main Contents
 

NAME

getcwd - (POSIX only) get current working directory pathname  

SYNOPSIS

char *getcwd(char *buf, size_t size);
 

DESCRIPTION

Getcwd is a POSIX function. BSD provides this functionality with the getwd(3) function.

The getcwd function copies the absolute pathname of the current working directory to the array pointed to by buf and returns a pointer to the result. The size argument is the size in bytes of the array.

If buf is NULL, then getcwd allocates an array of char, copies the pathname and returns a pointer to the array.  

RETURN VALUE

Upon successful completion, getcwd returns the bufP argument. Otherwise, a NULL pointer is returned and errno is set to indicate the error.  

ERRORS

If any of the following conditions occurs, the getcwd function returns a NULL pointer and sets errno to the corresponding value:
[EAGAIN]
The buf argument is NULL and getcwd fails to allocate an array for the pathname.
[EINVAL]
The size argument is zero.
[ERANGE]
The size argument is greater than zero but smaller than the length of the absolute pathname of the current directory plus 1.
 

SEE ALSO

chdir(2), getwd(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 00:57:20 GMT, September 26, 2024