From 3800f441e49af78b95d403014459dbb9bb646e8a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Oct 2014 16:53:28 +0200 Subject: [PATCH] =?UTF-8?q?createDirs():=20Handle=20=E2=80=98path=E2=80=99?= =?UTF-8?q?=20being=20a=20symlink?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In particular, this fixes "nix-build -o /tmp/result" on Mac OS X (where /tmp is a symlink). --- src/libutil/util.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 0729bf647..436580651 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -383,6 +383,9 @@ Paths createDirs(const Path & path) created.push_back(path); } + if (S_ISLNK(st.st_mode) && stat(path.c_str(), &st) == -1) + throw SysError(format("statting symlink ‘%1%’") % path); + if (!S_ISDIR(st.st_mode)) throw Error(format("‘%1%’ is not a directory") % path); return created;