aboutsummaryrefslogtreecommitdiff
path: root/bdep/utility.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-18 20:43:41 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-27 14:23:07 +0300
commitf283fbea934a1a2bad3fa1df25a82717e6b11aac (patch)
tree6f3180be8ca67a8a7efe6e79c98b0366d0e9c099 /bdep/utility.hxx
parent07fdebdbb02fde71d6e656ddd46b967347417502 (diff)
Implement temp directory facility
Diffstat (limited to 'bdep/utility.hxx')
-rw-r--r--bdep/utility.hxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/bdep/utility.hxx b/bdep/utility.hxx
index 7bc1522..a8a755b 100644
--- a/bdep/utility.hxx
+++ b/bdep/utility.hxx
@@ -84,6 +84,28 @@ namespace bdep
extern const path repositories_file; // repositories.manifest
extern const path configurations_file; // configurations.manifest
+ // Temporary directory facility.
+ //
+ // This is normally .bdep/tmp/ but can also be some system-wide directory
+ // (e.g., /tmp/bdep-XXX/) if there is no bdep project. 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 new).
+ //
+ extern dir_path temp_dir;
+
+ auto_rmfile
+ tmp_file (const string& prefix);
+
+ auto_rmdir
+ tmp_dir (const string& prefix);
+
+ void
+ init_tmp (const dir_path& prj);
+
+ void
+ clean_tmp (bool ignore_errors);
+
// Process path (argv[0]).
//
extern const char* argv0;
@@ -113,6 +135,14 @@ namespace bdep
void
rm (const path&, uint16_t verbosity = 3);
+ enum class rm_error_mode {ignore, warn, fail};
+
+ void
+ rm_r (const dir_path&,
+ bool dir_itself = true,
+ uint16_t verbosity = 3,
+ rm_error_mode = rm_error_mode::fail);
+
// Run a process.
//
template <typename I, typename O, typename E, typename P, typename... A>