ggeettccwwdd() -- General Function (libc)

Get current working directory name
#iinncclluuddee <uunniissttdd.hh>
cchhaarr *ggeettccwwdd(_b_u_f_f_e_r, _s_i_z_e)
cchhaarr *_b_u_f_f_e_r;
iinntt _s_i_z_e;

The  current  working  directory  is  the  directory from  which  file-name
searches  commence when  a path  name  does not  begin with  `/'.  ggeettccwwdd()
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 _b_u_f_f_e_r  is not  NULL, ggeettccwwdd()  writes the path  of the  current working
directory into  it.  The  expected path  name must not  be longer  than two
characters less than _s_i_z_e. In this case, ggeettccwwdd() returns _b_u_f_f_e_r.

If  _b_u_f_f_e_r is  NULL, ggeettccwwdd()  mmaalllloocc()'s _s_i_z_e  bytes.  ggeettccwwdd()  returns a
pointer to this block of memory.  You can ffrreeee() it later.

If  you do  not  have permission  to  search all  levels  of the  directory
hierarchy above the current directory, ggeettccwwdd() cannot obtain the directory
name for you.

_S_e_e _A_l_s_o
cchhddiirr(), lliibbcc, ppwwdd, uunniissttdd.hh
POSIX Standard, section 5.2.2

_D_i_a_g_n_o_s_t_i_c_s
ggeettccwwdd() returns  NULL and sets eerrrrnnoo  to an appropriate value  if an error
occurs.  Possible errors include the following:

EEPPEERRMM   Could not read one of the parent directories.

EEIINNVVAALL  _s_i_z_e is zero.

EENNOOMMEEMM  Memory could not be mmaalllloocc()'d for the buffer.

EERRAANNGGEE  The path name is too long to fit into _s_i_z_e minus two bytes.

_N_o_t_e_s
If ggeettccwwdd() fails, the working  directory cannot be restored to its initial
value.
