From 47afaabfe8d8d05df923bf43131cfbf9506b7983 Mon Sep 17 00:00:00 2001 From: Dmitry Lomov Date: Fri, 19 Feb 2016 08:21:13 +0000 Subject: Windows: use junctions to link to installation directory. Win32 have no good API for that (basically we need to resort to ioctl call). Shelling out to mklink. Needed for #276. -- MOS_MIGRATED_REVID=115040968 --- src/main/cpp/blaze.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/cpp/blaze.cc') diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc index 0c4fa76a79..336dbc2d8e 100644 --- a/src/main/cpp/blaze.cc +++ b/src/main/cpp/blaze.cc @@ -1009,6 +1009,8 @@ static void EnsureCorrectRunningVersion() { // installation is running. string installation_path = globals->options.output_base + "/install"; char prev_installation[PATH_MAX + 1] = ""; // NULs the whole array + // TODO(dslomov): On Windows, readlink always fails, + // so we do the linking every time. if (readlink(installation_path.c_str(), prev_installation, PATH_MAX) == -1 || prev_installation != globals->options.install_base) { @@ -1016,8 +1018,8 @@ static void EnsureCorrectRunningVersion() { globals->restart_reason = NEW_VERSION; } unlink(installation_path.c_str()); - if (symlink(globals->options.install_base.c_str(), - installation_path.c_str())) { + if (!SymlinkDirectories(globals->options.install_base.c_str(), + installation_path.c_str())) { pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, "failed to create installation symlink '%s'", installation_path.c_str()); -- cgit v1.2.3