aboutsummaryrefslogtreecommitdiff
path: root/bpkg/utility.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bpkg/utility.cxx')
-rw-r--r--bpkg/utility.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx
index 3cb9fb5..3529d83 100644
--- a/bpkg/utility.cxx
+++ b/bpkg/utility.cxx
@@ -262,6 +262,26 @@ namespace bpkg
}
}
+ dir_path
+ change_wd (const dir_path& d)
+ {
+ try
+ {
+ dir_path r (dir_path::current_directory ());
+
+ if (verb >= 3)
+ text << "cd " << d; // Prints trailing slash.
+
+ dir_path::current_directory (d);
+ return r;
+ }
+ catch (const system_error& e)
+ {
+ fail << "unable to change current directory to " << d << ": " << e
+ << endf;
+ }
+ }
+
fdpipe
open_pipe ()
{