aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)