about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-02-01T13·48+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-02-01T13·48+0000
commit630ae0c9d7f65a2d6bef85a5194b4d704e54eded (patch)
tree1cbb2dce71e58abb4617239857bbd144b1f355c1 /src/libutil
parentdcc37c236c66ba463bd61fec23d046485d8a412f (diff)
* nix-build: use an indirection scheme to make it easier for users to
  get rid of GC roots.  Nix-build places a symlink `result' in the
  current directory.  Previously, removing that symlink would not
  remove the store path being linked to as a GC root.  Now, the GC
  root created by nix-build is actually a symlink in
  `/nix/var/nix/gcroots/auto' to `result'.  So if that symlink is
  removed the GC root automatically becomes invalid (since it can no
  longer be resolved).  The root itself is not automatically removed -
  the garbage collector should delete dangling roots.

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 5b6fb62026c7..108c054b7f41 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 104e3f2651b4..d9d5a7cdfc53 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);