Gets the path name of the current directory.
Standard C Library (libc.a)
char *getcwd ( Buffer, Size)
The getcwd subroutine places the absolute path name of the current working directory in the array pointed to by the Buffer parameter, and returns that path name. The size parameter specifies the size in bytes of the character array pointed to by the Buffer parameter.
|Buffer||Points to string space that will contain the path name. If the Buffer parameter value is a null pointer, the getcwd subroutine, using the malloc subroutine, obtains the number of bytes of free space as specified by the Size parameter. In this case, the pointer returned by the getcwd subroutine can be used as the parameter in a subsequent call to the free subroutine. Starting the getcwd subroutine with a null pointer as the Buffer parameter value is not recommended.|
|Size||Specifies the length of the string space. The value of the Size parameter must be at least 1 greater than the length of the path name to be returned.|
If the getcwd subroutine is unsuccessful, a null value is returned and the errno global variable is set to indicate the error. The getcwd subroutine is unsuccessful if the Size parameter is not large enough or if an error occurs in a lower-level function.
If the getcwd subroutine
is unsuccessful, it returns one or more of the following error codes:
|EACCES||Indicates that read or search permission was denied for a component of the path name|
|EINVAL||Indicates that the Size parameter is 0 or a negative number.|
|ENOMEM||Indicates that insufficient storage space is available.|
|ERANGE||Indicates that the Size parameter is greater than 0, but is smaller than the length of the path name plus 1.|
This subroutine is part of Base Operating System (BOS) Runtime.
The getwd (getwd Subroutine) subroutine, malloc (malloc, free, realloc, calloc, mallopt, mallinfo, alloca, or valloc Subroutine) subroutine.
Files, Directories, and File Systems for Programmers in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.