diff options
Diffstat (limited to 'bpkg/utility.cxx')
-rw-r--r-- | bpkg/utility.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx new file mode 100644 index 0000000..c274563 --- /dev/null +++ b/bpkg/utility.cxx @@ -0,0 +1,46 @@ +// file : bpkg/utility.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <bpkg/utility> + +#include <system_error> + +#include <butl/filesystem> + +#include <bpkg/types> +#include <bpkg/diagnostics> + +using namespace std; +using namespace butl; + +namespace bpkg +{ + bool + exists (const path& f) + { + try + { + return file_exists (f); + } + catch (const system_error& e) + { + error << "unable to stat path " << f << ": " << e.what (); + throw failed (); + } + } + + bool + exists (const dir_path& d) + { + try + { + return file_exists (d); + } + catch (const system_error& e) + { + error << "unable to stat path " << d << ": " << e.what (); + throw failed (); + } + } +} |