diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-09-09 18:29:37 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-09-13 13:03:19 +0300 |
commit | dc1b424b75f200a716c3bd9b91891cf7f818ad32 (patch) | |
tree | 6c1625d8a52ad7ddc642da72f3c1f8896b617ff2 /build2/filesystem.cxx | |
parent | c49a4f0aeefd04ea6a269693d47d1e9d91ed8ad7 (diff) |
Fix crashing on unhandled system_error thrown by file_exists()
Diffstat (limited to 'build2/filesystem.cxx')
-rw-r--r-- | build2/filesystem.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/build2/filesystem.cxx b/build2/filesystem.cxx index 44b0ba4..c9696dc 100644 --- a/build2/filesystem.cxx +++ b/build2/filesystem.cxx @@ -79,7 +79,7 @@ namespace build2 if (work.sub (d)) // Don't try to remove working directory. return rmdir_status::not_empty; - if (!dir_exists (d)) + if (!exists (d)) return rmdir_status::not_exist; if (verb >= v) @@ -96,4 +96,32 @@ namespace build2 return rmdir_status::success; } + + bool + exists (const path& f, bool fs) + { + try + { + return file_exists (f, fs); + } + catch (const system_error& e) + { + error << "unable to stat path " << f << ": " << e.what (); + throw failed (); + } + } + + bool + exists (const dir_path& d) + { + try + { + return dir_exists (d); + } + catch (const system_error& e) + { + error << "unable to stat path " << d << ": " << e.what (); + throw failed (); + } + } } |