|
||
char *getcwd ( char *buf, int length )
char *buf; // character buffer to receive directory name int length; // size of buffer
|
|
|
Synopsis |
#include "silver.h"
The getcwd function retrieves the current working directory, and stores it into the character array pointed to by buf . If buf is NULL , then length bytes of storage are allocated by malloc , and the current directory is copied there.
|
|
Parameters |
buf is either a pointer to a character buffer, or NULL . If buf is non-NULL , then it should be at least length bytes in length.
|
|
Return Value |
getcwd returns buf , if buf was non-NULL ; otherwise, the address of the allocated storage is returned. If an error is returned, and errno is set to ENOMEM if buf was passed as NULL , but length bytes could not be allocated, or ERANGE if the current working directory as longer than length bytes.
|
|
|
|