From d7d4def945b38133c43e3df3ea7c450b229d2bfb Mon Sep 17 00:00:00 2001 From: Laszlo Csomor Date: Wed, 15 Feb 2017 13:07:52 +0000 Subject: Bazel client, JNI, Windows: impl. CreateJunction Implement a CreateJunction function in the Windows JNI library. Also move a bit of code from file_windows to the JNI library, where it is (also) needed. This implementation is an improved version of `blaze_util::SymlinkDirectories` in blaze_util_windows: this version handles Windows paths as `name` and `target`, and performs more validation (e.g. on the length of `target`), plus has more comments explaining the logic. In a subsequent change I'll start using this new function in blaze_util_windows. This method will also be helpful in tests: we will no longer have to shell out to mklink. See https://github.com/bazelbuild/bazel/issues/2107 -- Change-Id: I7e9b085fdc2ba47be83da5319bded02bd323e71b Reviewed-on: https://cr.bazel.build/8892 PiperOrigin-RevId: 147585207 MOS_MIGRATED_REVID=147585207 --- src/main/cpp/util/file_windows.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/main/cpp/util') diff --git a/src/main/cpp/util/file_windows.cc b/src/main/cpp/util/file_windows.cc index 9d22444dc8..e2e12950eb 100644 --- a/src/main/cpp/util/file_windows.cc +++ b/src/main/cpp/util/file_windows.cc @@ -35,6 +35,7 @@ using std::pair; using std::string; using std::unique_ptr; using std::wstring; +using windows_util::HasUncPrefix; // Returns the current working directory as a Windows path. // The result may have a UNC prefix. @@ -101,12 +102,6 @@ static bool HasDriveSpecifierPrefix(const char_type* ch) { return CharTraits::IsAlpha(ch[0]) && ch[1] == ':'; } -template -static bool HasUncPrefix(const char_type* path) { - return path[0] == '\\' && (path[1] == '\\' || path[1] == '?') && - (path[2] == '.' || path[2] == '?') && path[3] == '\\'; -} - static void AddUncPrefixMaybe(wstring* path) { if (path->size() >= MAX_PATH && !HasUncPrefix(path->c_str())) { *path = wstring(L"\\\\?\\") + *path; -- cgit v1.2.3