getcwd [ MPE/iX Developer's Kit Reference Manual Volume I ] MPE/iX 5.0 Documentation
MPE/iX Developer's Kit Reference Manual Volume I
getcwd
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:
EACCES CAUSE The 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.
ACTION Make sure that the calling process has search
permission to all component directories in the
pathname and read permission to the current working
directory.
EFAULT CAUSE The system detected a NULL or bad address in
attempting to use the buffer parameter.
ACTION Make sure that the pointer is correctly initialized.
EINVAL CAUSE The size parameter is equal to zero.
ACTION Make sure that the size parameter is greater than
zero.
ERANGE CAUSE The size parameter specifies a length that is less
than the size of the current working directory
pathname plus one.
ACTION Pass enough buffer area to contain a full pathname.
ESYSERR CAUSE An operating system error has occurred that does not
map directly to any of the above errors.
ACTION Examine the MPE/iX error stack for the type of system
error.
See Also
chdir(), POSIX.1 (Section 5.2.2)
MPE/iX 5.0 Documentation