about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc9
-rw-r--r--src/libutil/util.hh2
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 5b6fb62026..108c054b7f 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -135,6 +135,15 @@ Path readLink(const Path & path)
 }
 
 
+bool isLink(const Path & path)
+{
+    struct stat st;
+    if (lstat(path.c_str(), &st))
+        throw SysError(format("getting status of `%1%'") % path);
+    return S_ISLNK(st.st_mode);
+}
+
+
 Strings readDirectory(const Path & path)
 {
     Strings names;
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 104e3f2651..d9d5a7cdfc 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -84,6 +84,8 @@ bool pathExists(const Path & path);
    in any way canonicalised. */
 Path readLink(const Path & path);
 
+bool isLink(const Path & path);
+
 /* Read the contents of a directory.  The entries `.' and `..' are
    removed. */
 Strings readDirectory(const Path & path);