aboutsummaryrefslogtreecommitdiff
path: root/bpkg/utility.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-01-16 09:34:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-01-16 09:34:47 +0200
commite2d59d4a05b7624570c6398b3a6d095138d0d241 (patch)
tree4e5d1fbe19c09bbf0ac1dd933ad3543cfed40fba /bpkg/utility.hxx
parent2862f91f6016bd07fd9adc0a0f518258a32aa274 (diff)
Implement temp directory facility
Diffstat (limited to 'bpkg/utility.hxx')
-rw-r--r--bpkg/utility.hxx33
1 files changed, 29 insertions, 4 deletions
diff --git a/bpkg/utility.hxx b/bpkg/utility.hxx
index 8a1107c..e56e093 100644
--- a/bpkg/utility.hxx
+++ b/bpkg/utility.hxx
@@ -39,11 +39,33 @@ namespace bpkg
using butl::exception_guard;
using butl::make_exception_guard;
+ // Empty string and path.
+ //
+ extern const string empty_string;
+ extern const path empty_path;
+ extern const dir_path empty_dir_path;
+
// Widely-used paths.
//
extern const dir_path bpkg_dir; // .bpkg/
extern const dir_path certs_dir; // .bpkg/certs/
+ // Temporary directory.
+ //
+ // This is normally .bpkg/tmp/ but can also be some system-wide directory
+ // (e.g., /tmp/bpkg-XXX/) if there is no bpkg configuration. This directory
+ // is automatically created and cleaned up for most commands in main() so
+ // you don't need to call init_tmp() explicitly except for certain special
+ // commands (like cfg-create).
+ //
+ extern dir_path tmp_dir;
+
+ void
+ init_tmp (const dir_path& cfg);
+
+ void
+ clean_tmp (bool ignore_errors);
+
// Y/N prompt. The def argument, if specified, should be either 'y'
// or 'n'. It is used as the default answer, in case the user just
// hits enter. Issue diagnostics and throw failed if no answer could
@@ -55,10 +77,10 @@ namespace bpkg
// Filesystem.
//
bool
- exists (const path&);
+ exists (const path&, bool ignore_error = false);
bool
- exists (const dir_path&);
+ exists (const dir_path&, bool ignore_error = false);
bool
empty (const dir_path&);
@@ -70,10 +92,13 @@ namespace bpkg
mk_p (const dir_path&);
void
- rm (const path&);
+ rm (const path&, uint16_t verbosity = 3);
void
- rm_r (const dir_path&, bool dir = true);
+ rm_r (const dir_path&,
+ bool dir_itself = true,
+ uint16_t verbosity = 3,
+ bool ignore_error = false);
using auto_rm = butl::auto_rmfile;
using auto_rm_r = butl::auto_rmdir;