]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
cope with systems that don't have realpath()
authorAndrew Tridgell <tridge@samba.org>
Fri, 28 Mar 2003 11:59:41 +0000 (12:59 +0100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 28 Mar 2003 11:59:41 +0000 (12:59 +0100)
util.c

diff --git a/util.c b/util.c
index ff0c83cb846b0a07780e4b4f360482176d5e75f2..d2a920a237c05ef0fd8bfe772465b76762ef4772 100644 (file)
--- 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);