From 829c0083b1684e7513e0bd1bb0a92f767ba83f77 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 16 Sep 2015 16:11:00 +0200 Subject: Add rm(path) function --- bpkg/utility.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'bpkg/utility.cxx') 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) -- cgit v1.1