aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-16 16:11:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-16 16:11:00 +0200
commit829c0083b1684e7513e0bd1bb0a92f767ba83f77 (patch)
tree7ea2de1908d74cbc6656e6e53d2190d9eafde7e2
parent422afdb14a7a0c141bce59287377bca1b1b34a07 (diff)
Add rm(path) function
-rw-r--r--bpkg/utility3
-rw-r--r--bpkg/utility.cxx17
2 files changed, 20 insertions, 0 deletions
diff --git a/bpkg/utility b/bpkg/utility
index ea7dfa6..c1ef094 100644
--- a/bpkg/utility
+++ b/bpkg/utility
@@ -30,6 +30,9 @@ namespace bpkg
mk_p (const dir_path&);
void
+ rm (const path&);
+
+ void
rm_r (const dir_path&, bool dir = true);
// Process.
diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx
index 632791c..d9e0413 100644
--- a/bpkg/utility.cxx
+++ b/bpkg/utility.cxx
@@ -93,6 +93,23 @@ namespace bpkg
}
void
+ rm (const path& f)
+ {
+ if (verb >= 3)
+ text << "rm " << f;
+
+ try
+ {
+ if (try_rmfile (f) == rmfile_status::not_exist)
+ fail << "unable to remove file " << f << ": file does not exist";
+ }
+ catch (const system_error& e)
+ {
+ fail << "unable to remove file " << f << ": " << e.what ();
+ }
+ }
+
+ void
rm_r (const dir_path& d, bool dir)
{
if (verb >= 3)