about summary refs log tree commit diff
path: root/src/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/util.cc b/src/util.cc
index 65ceea938352..2f9c43e55ce5 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -33,13 +33,18 @@ string absPath(string path, string dir)
             dir = buf;
         }
         path = dir + "/" + path;
-        /* !!! canonicalise */
-        char resolved[PATH_MAX];
-        if (!realpath(path.c_str(), resolved))
-            throw SysError(format("cannot canonicalise path %1%") % path);
-        path = resolved;
     }
-    return path;
+    return canonPath(path);
+}
+
+
+string canonPath(const string & path)
+{
+    char resolved[PATH_MAX];
+    if (!realpath(path.c_str(), resolved))
+        throw SysError(format("cannot canonicalise path `%1%'") % path);
+    /* !!! check that this removes trailing slashes */
+    return resolved;
 }