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

need advice on readlink and PATH_MAX



Hrm, I'm trying to port limo and I have a slight problem, because it uses
readlink(). readlink expects a buffer and a length, which is great if I happen
to have a char[PATH_MAX], but ... we don't have PATH_MAX as you know. My idea
for a solution to this was to write a function myreadlink which returns an allocated
string based on making a huge string, loading it with readlink, checking if the
actual length returned by readlink is less than the alloctaed string (and then reallocing
it down), or if the length return was equal to the allocated string (and then reallocing
it up and doing the function again) .. repaating until the string is the right
length. This seems inefficient, but I'm not sure how else to do it. Any advice?

I saw the function realpath() which returns an allocated string, my concern in using
it is that it may not be as portable as readlink and that itmay return different things
than readlink under certain circumstances.

Thanks


as always,
nick
            nick@grawk.net * http://www.fargus.net/nick
    Developer - Systems Engineer - Mad System Guru - MOO Sales
    He picks up scraps of information/He's adept at adaptation
Because for strangers and arrangers/Constant change is here to stay



Reply to: