private static string readlink (string path)
{
if (readlinkNotFound)
return null;
byte[] buf = new byte [512];
int ret;
try {
ret = readlink (path, buf, buf.Length);
} catch (DllNotFoundException) {
readlinkNotFound = true;
return null;
} catch (EntryPointNotFoundException) {
readlinkNotFound = true;
return null;
}
if (ret == -1) return null;
char[] cbuf = new char [512];
int chars = System.Text.Encoding.Default.GetChars (buf, 0, ret, cbuf, 0);
return new String (cbuf, 0, chars);
}