1 /* Emulate getcwd using getwd.
2 This function is in the public domain. */
6 @deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})
8 Copy the absolute pathname for the current working directory into
9 @var{pathname}, which is assumed to point to a buffer of at least
10 @var{len} bytes, and return a pointer to the buffer. If the current
11 directory's path doesn't fit in @var{len} characters, the result is
12 @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
22 #ifdef HAVE_SYS_PARAM_H
23 #include <sys/param.h>
33 extern char *getwd ();
37 #define MAXPATHLEN 1024
41 getcwd (char *buf
, size_t len
)
43 char ourbuf
[MAXPATHLEN
];
46 result
= getwd (ourbuf
);
48 if (strlen (ourbuf
) >= len
) {
53 buf
= (char*)malloc(len
);
This page took 0.030582 seconds and 4 git commands to generate.