Re: libgcj
On Sun, Apr 02, 2000 at 12:11:24PM +0100, Chris Lingard wrote:
> Have looked at Hurd source for get_current_dir_name and ERANGE in the header files,
> and do not understand what you want. The problem is that names MAXHOSTNAMELEN,
> MAXPATHLEN (and NOFILES) are used like:
>
> buf[MAXHOSTNAMELEN]
>
> Please point me to an example of the code that you would like. What source package
> can I use as an example?
char *buf;
buf = get_current_dir_name();
The other way is to use realloc:
#ifndef MAXPATHLEN
#define MAXPATHLEN 2048
#endif
buffer = alloc(MAXPATHLEN);
while (max_len > 0)
{
buffer = realloc (max_len + 1);
*buffer = 0;
dir = getcwd (buffer, max_len);
if (dir || errno != ERANGE)
break;
free (buffer);
max_len *= 2;
}
or similar.
Thanks,
Marcus
--
`Rhubarb is no Egyptian god.' Debian http://www.debian.org Check Key server
Marcus Brinkmann GNU http://www.gnu.org for public PGP Key
Marcus.Brinkmann@ruhr-uni-bochum.de, marcus@gnu.org PGP Key ID 36E7CD09
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/ brinkmd@debian.org
Reply to:
- References:
- Re: libgcj
- From: Chris Lingard <chris@highludworth.freeserve.co.uk>