[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Path length in GEM file selector



In <9401201204.AA13974@urix6.uni-muenster.de>, Marcus Haebler wrote:

> there is a little problem with the path length in GEM programs if
> you use the normal length of 128 Bytes, this is quite small for
> Minix FSs etc. Should we set path length to 1024 like BSD does?

Since P1003.1 does not define a maximum length for a path, no application
should assume that there is one. You'll have to use something more
flexible than a compile time constant.

Here is an example with getcwd() :

#define PATHSIZE 1024

char *cwdname(void)
{
        int     size = PATHSIZE;
        char *  name;

        while(1)
        {       name = (char *) malloc(size);
                if( name = NULL )
                        FatalError("out of memory");
                if( getcwd(name, size-1) != NULL )
                        return name;
                if( errno != ERANGE )
                        FatalError("getcwd() failed");
                free(name);
                size += PATHSIZE;
        }
}


Regards,
           Waldi  (walra%moacs11@nl.net)