Skip to content

Commit

Permalink
Windows, build-runfiles: Fix bugs when dealing with long path
Browse files Browse the repository at this point in the history
We should make sure the path passing to Windows API has the \\?\ prefix.

Related #5807

RELNOTES: None
PiperOrigin-RevId: 211039921
  • Loading branch information
meteorcloudy authored and Copybara-Service committed Aug 31, 2018
1 parent fff72a7 commit cf791b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/tools/build-runfiles-windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ class RunfilesCreator {
}

link = AsAbsoluteWindowsPath(link.c_str());
if (!target.empty()) {
target = AsAbsoluteWindowsPath(target.c_str());
}

manifest_file_map.insert(make_pair(link, target));
}
Expand Down Expand Up @@ -257,6 +260,7 @@ class RunfilesCreator {
do {
if (kDot != metadata.cFileName && kDotDot != metadata.cFileName) {
wstring subpath = path + L"\\" + metadata.cFileName;
subpath = AsAbsoluteWindowsPath(subpath.c_str());
bool is_dir =
(metadata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
bool is_symlink =
Expand All @@ -268,7 +272,6 @@ class RunfilesCreator {
GetLastErrorString().c_str());
}

subpath = AsAbsoluteWindowsPath(subpath.c_str());
target = AsAbsoluteWindowsPath(target.c_str());
ManifestFileMap::iterator expected_target =
manifest_file_map.find(subpath);
Expand All @@ -277,8 +280,7 @@ class RunfilesCreator {
expected_target->second.empty()
// Both paths are normalized paths in lower case, we can compare
// them directly.
|| target !=
AsAbsoluteWindowsPath(expected_target->second.c_str()) ||
|| target != expected_target->second.c_str() ||
blaze_util::IsDirectoryW(target) != is_dir) {
if (is_dir) {
RemoveDirectoryOrDie(subpath);
Expand Down

0 comments on commit cf791b5

Please sign in to comment.