diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-01-16 10:29:18 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-01-16 10:29:18 +0200 |
commit | ce76d4774a9e9d6b6c57d2c21f45f289eedccd56 (patch) | |
tree | fed7459fbf40e14f6297d1911c39e0daf3a43f27 /bpkg/utility.cxx | |
parent | e2d59d4a05b7624570c6398b3a6d095138d0d241 (diff) |
Use tmp directory facility for storing temporary certificates
Diffstat (limited to 'bpkg/utility.cxx')
-rw-r--r-- | bpkg/utility.cxx | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx index d87c151..f32daa0 100644 --- a/bpkg/utility.cxx +++ b/bpkg/utility.cxx @@ -24,7 +24,21 @@ namespace bpkg const dir_path bpkg_dir (".bpkg"); const dir_path certs_dir (dir_path (bpkg_dir) /= "certs"); - dir_path tmp_dir; + static dir_path tmp_dir_; + + auto_rmfile + tmp_file (const string& p) + { + assert (!tmp_dir_.empty ()); + return auto_rmfile (tmp_dir_ / path::traits::temp_name (p)); + } + + auto_rmdir + tmp_dir (const string& p) + { + assert (!tmp_dir_.empty ()); + return auto_rmdir (tmp_dir_ / dir_path (path::traits::temp_name (p))); + } void init_tmp (const dir_path& cfg) @@ -42,15 +56,17 @@ namespace bpkg mk (d); // We shouldn't need mk_p(). - tmp_dir = move (d); + tmp_dir_ = move (d); } void clean_tmp (bool ignore_error) { - assert (!tmp_dir.empty ()); - rm_r (tmp_dir, true /* dir_itself */, 3, ignore_error); - tmp_dir.clear (); + if (!tmp_dir_.empty ()) + { + rm_r (tmp_dir_, true /* dir_itself */, 3, ignore_error); + tmp_dir_.clear (); + } } bool |