aboutsummaryrefslogtreecommitdiff
path: root/bpkg/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-07 15:49:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-07 15:49:44 +0200
commit8f94aaa067426a259f5396abdaf4945671799b5c (patch)
treefb64d4135cab2d36d2582dd7baf222e76e4d3bc5 /bpkg/utility.cxx
parent2858e5f80f836862400bf814ef1b2dcb0ff8a74e (diff)
Various fixes for rep-create
Diffstat (limited to 'bpkg/utility.cxx')
-rw-r--r--bpkg/utility.cxx46
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 ();
+ }
+ }
+}