|
NAMEgetcwd , getwd —
get working directory pathname
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <unistd.h>
char *
char *
DESCRIPTIONThegetcwd () function copies the absolute pathname of
the current working directory into the memory referenced by
buf and returns a pointer to buf.
The size argument is the size, in bytes, of the array
referenced by buf.
If buf is The function These routines have traditionally been used by programs to save
the name of a working directory for the purpose of returning to it. A much
faster and less error-prone method of accomplishing this is to open the
current directory (‘ RETURN VALUESUpon successful completion, a pointer to the pathname is returned. Otherwise aNULL pointer is returned and the global variable
errno is set to indicate the error. In addition,
getwd () copies the error message associated with
errno into the memory referenced by
buf.
ERRORSThegetcwd () function will fail if:
The
SEE ALSOchdir(2), fchdir(2), malloc(3), strerror(3)STANDARDSThegetcwd () function conforms to IEEE
Std 1003.1-1990 (“POSIX.1”). The ability to specify a
NULL pointer and have getcwd ()
allocate memory as necessary is an extension.
HISTORYThegetwd () function appeared in
4.0BSD.
BUGSThegetwd () function does not do sufficient error
checking and is not able to return very long, but valid, paths. It is provided
for compatibility.
Visit the GSP FreeBSD Man Page Interface. |