aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util_mingw.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/cpp/blaze_util_mingw.cc')
-rw-r--r--src/main/cpp/blaze_util_mingw.cc31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/main/cpp/blaze_util_mingw.cc b/src/main/cpp/blaze_util_mingw.cc
index d3ebfedaa1..c959f00f6d 100644
--- a/src/main/cpp/blaze_util_mingw.cc
+++ b/src/main/cpp/blaze_util_mingw.cc
@@ -115,12 +115,11 @@ void ReplaceAll(
pos += with.length();
}
}
-} // namespace
-// Replace the current process with the given program in the given working
-// directory, using the given argument vector.
-// This function does not return on success.
-void ExecuteProgram(const string& exe, const vector<string>& args_vector) {
+// Run the given program in the current working directory,
+// using the given argument vector.
+DWORD CreateProcessWrapper(
+ const string& exe, const vector<string>& args_vector) {
if (VerboseLogging()) {
string dbg;
for (const auto& s : args_vector) {
@@ -212,9 +211,16 @@ void ExecuteProgram(const string& exe, const vector<string>& args_vector) {
GetExitCodeProcess(pi.hProcess, &exit_code);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
+ return exit_code;
+}
+} // namespace
+// Replace the current process with the given program in the current working
+// directory, using the given argument vector.
+// This function does not return on success.
+void ExecuteProgram(const string& exe, const vector<string>& args_vector) {
// Emulate execv.
- exit(exit_code);
+ exit(CreateProcessWrapper(exe, args_vector));
}
string ListSeparator() { return ";"; }
@@ -227,4 +233,17 @@ string ConvertPath(const string& path) {
return result;
}
+bool SymlinkDirectories(const string &target, const string &link) {
+ const string target_win = ConvertPath(target);
+ const string link_win = ConvertPath(link);
+ vector<string> args;
+ args.push_back("cmd");
+ args.push_back("/C");
+ args.push_back("mklink");
+ args.push_back("/J");
+ args.push_back(link_win);
+ args.push_back(target_win);
+ return CreateProcessWrapper("cmd", args) == 0;
+}
+
} // namespace blaze