Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getcwd(3C) — sys5 — Apollo Domain/OS SR10.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

malloc(3C)

popen(3S)

pwd(1)

GETCWD(3C)                           SysV                           GETCWD(3C)



NAME
     getcwd - get pathname of current working directory

SYNOPSIS
     char *getcwd (buf, size)
     char *buf;
     int size;

DESCRIPTION
     getcwd returns a pointer to the current directory pathname.  The value of
     size must be at least two greater than the length of the pathname to be
     returned.

     If buf is a NULL pointer, getcwd will obtain size bytes of space using
     malloc(3C).  In this case, the pointer returned by getcwd may be used as
     the argument in a subsequent call to free.

EXAMPLE
          void exit(), perror();
          .
          .
          .
          if ((cwd = getcwd((char *)NULL, 64)) == NULL) {
               perror("pwd");
               exit(2);
          }
          printf("%s\n", cwd);

DIAGNOSTICS
     Upon successful completion, the buf argument is returned.  Otherwise, a
     null value is returned and errno is set to indicate the error.  The
     contents of the array pointed to by buf are undefined after an error.

ERRORS
     If the getcwd function fails, errno is set to one of the following
     values:

     [EINVAL]  The size parameter is zero or negative.

     [ERANGE]  The size parameter is greater than zero, but is smaller than
               the length of the pathname + 1.

     [EACCES]  The caller does not have READ and SEARCH rights to each
               directory in the returned pathname.

SEE ALSO
     malloc(3C), popen(3S).
     pwd(1) in the SysV Command Reference.

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