aboutsummaryrefslogtreecommitdiff
path: root/build/file.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-24 16:30:49 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-24 16:30:49 +0200
commitf5d7278fbe047c15d9d637b33aeb91865ddecb1e (patch)
tree511ccce041751186dc1e526f9de5274c0c2d52fe /build/file.cxx
parentcac5a679fe00aa6e57480ed6f52d120e9a0ef4a7 (diff)
Account for dangling/inaccessible links
Diffstat (limited to 'build/file.cxx')
-rw-r--r--build/file.cxx13
1 files changed, 12 insertions, 1 deletions
diff --git a/build/file.cxx b/build/file.cxx
index 278cd5d..7e3555f 100644
--- a/build/file.cxx
+++ b/build/file.cxx
@@ -357,8 +357,19 @@ namespace build
for (const dir_entry& de: dir_iterator (d))
{
- if (de.type () != entry_type::directory)
+ // If this is a link, then type() will try to stat() it. And if
+ // the link is dangling or points to something inaccessible, it
+ // will fail.
+ //
+ try
+ {
+ if (de.type () != entry_type::directory)
+ continue;
+ }
+ catch (const system_error& e)
+ {
continue;
+ }
dir_path sd (d / path_cast<dir_path> (de.path ()));