From 00cda575c97494d1b6caf2d05ea8a1f8e848cd8a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 3 Jun 2022 21:53:48 +0300 Subject: Add --keep-temp common option --- bpkg/utility.cxx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'bpkg/utility.cxx') diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx index 625348b..d229205 100644 --- a/bpkg/utility.cxx +++ b/bpkg/utility.cxx @@ -36,22 +36,26 @@ namespace bpkg const dir_path current_dir ("."); - map temp_dir; + map tmp_dirs; + + bool keep_tmp; auto_rmfile tmp_file (const dir_path& cfg, const string& p) { - auto i (temp_dir.find (cfg)); - assert (i != temp_dir.end ()); - return auto_rmfile (i->second / path::traits_type::temp_name (p)); + auto i (tmp_dirs.find (cfg)); + assert (i != tmp_dirs.end ()); + return auto_rmfile (i->second / path::traits_type::temp_name (p), + !keep_tmp); } auto_rmdir tmp_dir (const dir_path& cfg, const string& p) { - auto i (temp_dir.find (cfg)); - assert (i != temp_dir.end ()); - return auto_rmdir (i->second / dir_path (path::traits_type::temp_name (p))); + auto i (tmp_dirs.find (cfg)); + assert (i != tmp_dirs.end ()); + return auto_rmdir (i->second / dir_path (path::traits_type::temp_name (p)), + !keep_tmp); } void @@ -72,13 +76,13 @@ namespace bpkg mk (d); // We shouldn't need mk_p(). - temp_dir[cfg] = move (d); + tmp_dirs[cfg] = move (d); } void clean_tmp (bool ignore_error) { - for (const auto& d: temp_dir) + for (const auto& d: tmp_dirs) { const dir_path& td (d.second); @@ -91,7 +95,7 @@ namespace bpkg } } - temp_dir.clear (); + tmp_dirs.clear (); } path& -- cgit v1.1