From: Andrew Tridgell Date: Fri, 28 Mar 2003 11:59:41 +0000 (+0100) Subject: cope with systems that don't have realpath() X-Git-Tag: v2.3~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e918ccc;p=thirdparty%2Fccache.git cope with systems that don't have realpath() --- diff --git a/util.c b/util.c index ff0c83cb8..d2a920a23 100644 --- a/util.c +++ b/util.c @@ -359,8 +359,22 @@ char *x_realpath(const char *path) if (maxlen < 4096) maxlen = 4096; ret = x_malloc(maxlen); - + +#if HAVE_REALPATH p = realpath(path, ret); +#else + /* yes, there are such systems. This replacement relies on + the fact that when we call x_realpath we only care about symlinks */ + { + int len = readlink(path, ret, maxlen-1); + if (len == -1) { + free(ret); + return NULL; + } + ret[len] = 0; + p = ret; + } +#endif if (p) { p = x_strdup(p); free(ret);