Mail Archives: djgpp/1993/03/09/20:28:49
> Does anyone know how to obtain the full path name of the current
> directory which works on (every) --> UNIX <-- (POSIX preferably)
> and therefore also on DJGPP ?
I believe that the POSIX answer is:
#include <unistd.h>
char *getcwd(char *buf, size_t size);
You pass it a buffer <buf> of size <size> bytes, and getcwd() fills in
the buffer with the current working directory, and then returns <buf>.
If something fails (like <size> is too small) the function returns
NULL and sets errno. I believe that PATH_MAX bytes should always be
big enough to hold the path. Or maybe you need PATH_MAX+1 for the
null. I can't remember.
Offhand, I don't recall if DJGPP supports this, but I'd bet it does.
(If not, please write a getcwd() and send it to the mailing list so it
gets into the next release of DJGPP.)
Unfortunately, I believe that this is one of those areas where every
UNIX system before POSIX did things slightly differently.
--
Eric Backus
ericb AT lsid DOT hp DOT com
(206) 335-2495
- Raw text -