Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getcwd(3P) — OPENSTEP 4.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chdir(2)

getwd(3)

GETCWD(3P)  —  UNIX Programmer’s Manual

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)

POSIX 1003.1  —  August 1, 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026