aboutsummaryrefslogtreecommitdiff
path: root/bpkg/utility.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-06-03 21:53:48 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-06-07 13:49:14 +0300
commit00cda575c97494d1b6caf2d05ea8a1f8e848cd8a (patch)
tree19adfe4823b460367b80630c2b43ed553fc391a0 /bpkg/utility.cxx
parentdeecf4971fbc90b472135e30387bc76e9788061b (diff)
Add --keep-temp common option
Diffstat (limited to 'bpkg/utility.cxx')
-rw-r--r--bpkg/utility.cxx24
1 files changed, 14 insertions, 10 deletions
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<dir_path, dir_path> temp_dir;
+ map<dir_path, dir_path> 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&