COHERENT manpages
This page displays the COHERENT manpage for getcwd() [Get current working directory name].
List of available manpages
Index
getcwd() -- General Function (libc) Get current working directory name #include <unistd.h> char *getcwd(buffer, size) char *buffer; int size; The current working directory is the directory from which file-name searches commence when a path name does not begin with `/'. getcwd() returns the name of the current working directory. It is useful for processes like spoolers and daemons, which must generate full path names for files. If buffer is not NULL, getcwd() writes the path of the current working directory into it. The expected path name must not be longer than two characters less than size. In this case, getcwd() returns buffer. If buffer is NULL, getcwd() malloc()'s size bytes. getcwd() returns a pointer to this block of memory. You can free() it later. If you do not have permission to search all levels of the directory hierarchy above the current directory, getcwd() cannot obtain the directory name for you. See Also chdir(), libc, pwd, unistd.h POSIX Standard §5.2.2 Diagnostics getcwd() returns NULL and sets errno to an appropriate value if an error occurs. Possible errors include the following: EPERM Could not read one of the parent directories. EINVAL size is zero. ENOMEM Memory could not be malloc()'d for the buffer. ERANGE The path name is too long to fit into size minus two bytes. Notes If getcwd() fails, the working directory cannot be restored to its initial value.