HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

getcwd

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Returns the pathname of the current working directory.

Syntax

   #include <sys/types.h>

   #include <unistd.h>

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

Parameters

buffer

A pointer to a character array where an absolute pathname for the calling process's current working directory is returned. The pathname must be terminated by a null character. The size of the array must be large enough to contain the length of the pathname plus the terminating null character.

size

The size, in bytes, of the array pointed to by buffer.

Return Values

<>NULL

Success. A pointer to buffer is returned.

NULL

An error occurred. The contents of buffer are undefined, and errno is set to indicate the error condition.

Description

The getcwd() function places in the array pointed to by buffer the absolute pathname of the calling process's current working directory. Any contents of buffer past the terminating null character are undefined. If an error occurs, the contents of the buffer are undefined.

Implementation Considerations

Refer to the EFAULT and ESYSERR error descriptions below.

Errors

If an error occurs, errno is set to one of the following values:

EACCESCAUSEThe calling process either does not have search permission to a component of the pathname or does not have read permission to the current working directory.
 ACTIONMake sure that the calling process has search permission to all component directories in the pathname and read permission to the current working directory.
EFAULTCAUSEThe system detected a NULL or bad address in attempting to use the buffer parameter.
 ACTIONACTION
EINVALCAUSEThe size parameter is equal to zero.
 ACTIONMake sure that the size parameter is greater than zero.
ERANGECAUSEThe size parameter specifies a length that is less than the size of the current working directory pathname plus one.
 ACTIONPass enough buffer area to contain a full pathname.
ESYSERRCAUSEAn operating system error has occurred that does not map directly to any of the above errors.
 ACTIONExamine the MPE/iX error stack for the type of system error.

See Also

chdir(), POSIX.1 (Section 5.2.2)

Feedback to webmaster