Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getcwd(3) — CLIX 3.1r7.6.28

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

malloc(3)



  getcwd(3)                           CLIX                           getcwd(3)



  NAME

    getcwd - Gets the pathname of the current directory

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    char *getcwd(
      char *buffer ,
      int size );

  PARAMETERS

    buffer   Points to a string space to hold the pathname.  If the buffer
             parameter is a NULL pointer, getcwd(), using the malloc()
             function, obtains the number of bytes of free space as specified
             by the size parameter.  In this case, the pointer returned by
             getcwd() can be used as the parameter in a subsequent call to the
             free() function.

    size     Specifies the length of the string space.  The value of the size
             parameter must be at least 2 greater than the length of the
             pathname to be returned.

  DESCRIPTION

    The getcwd() function returns a pointer to a string containing the
    pathname of the current directory.

  EXAMPLES

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


  RETURN VALUES

    If getcwd() fails, a NULL value is returned and the global variable errno
    is set to indicate the error.  If getcwd() is successful, it returns a
    pointer to a string containing the pathname of the current directory.

  ERRORS

    If any of the following conditions occur, the getcwd function returns a



  2/94 - Intergraph Corporation                                              1






  getcwd(3)                           CLIX                           getcwd(3)



    value of NULL and sets errno to the corresponding value:

    [EINVAL]   The size argument is less than or equal to 0.

    [ERANGE]   The size argument is greater than 0, but is smaller than the
               length of the pathname plus 1.

    [EACCES]   Read or search permission was denied for a component of the
               pathname.

  RELATED INFORMATION

    Functions:  malloc(3)









































  2                                              Intergraph Corporation - 2/94




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