2 |
This function is in the public domain. */ |
This function is in the public domain. */ |
3 |
|
|
4 |
/* |
/* |
|
NAME |
|
|
getcwd -- get absolute pathname for current working directory |
|
5 |
|
|
6 |
SYNOPSIS |
@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len}) |
|
char *getcwd (char pathname[len], len) |
|
7 |
|
|
8 |
DESCRIPTION |
Copy the absolute pathname for the current working directory into |
9 |
Copy the absolute pathname for the current working directory into |
@var{pathname}, which is assumed to point to a buffer of at least |
10 |
the supplied buffer and return a pointer to the buffer. If the |
@var{len} bytes, and return a pointer to the buffer. If the current |
11 |
current directory's path doesn't fit in LEN characters, the result |
directory's path doesn't fit in @var{len} characters, the result is |
12 |
is NULL and errno is set. |
@code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer, |
13 |
|
@code{getcwd} will obtain @var{len} bytes of space using |
14 |
If pathname is a null pointer, getcwd() will obtain size bytes of |
@code{malloc}. |
15 |
space using malloc. |
|
16 |
|
@end deftypefn |
|
BUGS |
|
|
Emulated via the getwd() call, which is reasonable for most |
|
|
systems that do not have getcwd(). |
|
17 |
|
|
18 |
*/ |
*/ |
19 |
|
|
40 |
char * |
char * |
41 |
getcwd (buf, len) |
getcwd (buf, len) |
42 |
char *buf; |
char *buf; |
43 |
int len; |
size_t len; |
44 |
{ |
{ |
45 |
char ourbuf[MAXPATHLEN]; |
char ourbuf[MAXPATHLEN]; |
46 |
char *result; |
char *result; |