aboutsummaryrefslogtreecommitdiff
path: root/bpkg/utility.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-02-12 17:30:16 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-12 17:34:55 +0300
commitb7763416f8a1e4940a10336d3a8b9fbbb879f414 (patch)
tree31f1bc7427181aa81984a639d998ca4e99058199 /bpkg/utility.cxx
parentecb1efeebaa5597bee4cfdaab7bff4007b73127d (diff)
Clone and fetch git repositories
Diffstat (limited to 'bpkg/utility.cxx')
-rw-r--r--bpkg/utility.cxx39
1 files changed, 29 insertions, 10 deletions
diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx
index f32daa0..75ba102 100644
--- a/bpkg/utility.cxx
+++ b/bpkg/utility.cxx
@@ -22,22 +22,25 @@ namespace bpkg
const dir_path empty_dir_path;
const dir_path bpkg_dir (".bpkg");
- const dir_path certs_dir (dir_path (bpkg_dir) /= "certs");
+ const dir_path certs_dir (dir_path (bpkg_dir) /= "certificates");
+ const dir_path repos_dir (dir_path (bpkg_dir) /= "repositories");
- static dir_path tmp_dir_;
+ const dir_path current_dir (".");
+
+ dir_path temp_dir;
auto_rmfile
tmp_file (const string& p)
{
- assert (!tmp_dir_.empty ());
- return auto_rmfile (tmp_dir_ / path::traits::temp_name (p));
+ assert (!temp_dir.empty ());
+ return auto_rmfile (temp_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)));
+ assert (!temp_dir.empty ());
+ return auto_rmdir (temp_dir / dir_path (path::traits::temp_name (p)));
}
void
@@ -56,16 +59,16 @@ namespace bpkg
mk (d); // We shouldn't need mk_p().
- tmp_dir_ = move (d);
+ temp_dir = move (d);
}
void
clean_tmp (bool ignore_error)
{
- if (!tmp_dir_.empty ())
+ if (!temp_dir.empty ())
{
- rm_r (tmp_dir_, true /* dir_itself */, 3, ignore_error);
- tmp_dir_.clear ();
+ rm_r (temp_dir, true /* dir_itself */, 3, ignore_error);
+ temp_dir.clear ();
}
}
@@ -213,6 +216,22 @@ namespace bpkg
}
}
+ void
+ mv (const dir_path& from, const dir_path& to)
+ {
+ if (verb >= 3)
+ text << "mv " << from << " to " << to; // Prints trailing slashes.
+
+ try
+ {
+ mvdir (from, to);
+ }
+ catch (const system_error& e)
+ {
+ fail << "unable to move directory " << from << " to " << to << ": " << e;
+ }
+ }
+
dir_path exec_dir;
void