1 /* Emulate getcwd using getwd.
2 This function is in the public domain. */
6 getcwd -- get absolute pathname for current working directory
9 char *getcwd (char pathname[len], len)
12 Copy the absolute pathname for the current working directory into
13 the supplied buffer and return a pointer to the buffer. If the
14 current directory's path doesn't fit in LEN characters, the result
15 is NULL and errno is set.
17 If pathname is a null pointer, getcwd() will obtain size bytes of
21 Emulated via the getwd() call, which is reasonable for most
22 systems that do not have getcwd().
28 #ifdef HAVE_SYS_PARAM_H
29 #include <sys/param.h>
39 extern char *getwd ();
43 #define MAXPATHLEN 1024
51 char ourbuf
[MAXPATHLEN
];
54 result
= getwd (ourbuf
);
56 if (strlen (ourbuf
) >= len
) {
61 buf
= (char*)malloc(len
);