diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-01-23 15:14:03 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2017-01-23 15:16:17 +0000 |
commit | 50c13ce372a889422ec2efbcd68298f8fb6c66a8 (patch) | |
tree | d7c066436891f5fdd3acfacc253947169ed53886 /src/main/cpp/util | |
parent | a4342784d67e2cdad2068d51dcf74cc856c89061 (diff) |
Rollback of commit d5527469ca629f806a7576783289cc0613bf418b.
*** Reason for rollback ***
Breaks Bazel-Install-Trigger on CI.
*** Original change description ***
Bazel client, Windows: impl. ForEachDirectoryEntry
Implement ForEachDirectoryEntry on Windows using
FindFirstFileW / FindNextFileW.
Supports long paths and traversing junctions.
See https://github.com/bazelbuild/bazel/issues/2107
See https://github.com/bazelbuild/bazel/issues/2181
--
PiperOrigin-RevId: 145282158
MOS_MIGRATED_REVID=145282158
Diffstat (limited to 'src/main/cpp/util')
-rw-r--r-- | src/main/cpp/util/file_posix.cc | 2 | ||||
-rw-r--r-- | src/main/cpp/util/file_windows.cc | 33 |
2 files changed, 6 insertions, 29 deletions
diff --git a/src/main/cpp/util/file_posix.cc b/src/main/cpp/util/file_posix.cc index c45eb3915c..a1d806a9d9 100644 --- a/src/main/cpp/util/file_posix.cc +++ b/src/main/cpp/util/file_posix.cc @@ -364,6 +364,7 @@ string GetCwd() { bool ChangeDirectory(const string& path) { return chdir(path.c_str()) == 0; } +#endif // not __CYGWIN__ void ForEachDirectoryEntry(const string &path, DirectoryEntryConsumer *consume) { @@ -397,6 +398,5 @@ void ForEachDirectoryEntry(const string &path, closedir(dir); } -#endif // not __CYGWIN__ } // namespace blaze_util diff --git a/src/main/cpp/util/file_windows.cc b/src/main/cpp/util/file_windows.cc index bea092d9ff..b1fadddf4a 100644 --- a/src/main/cpp/util/file_windows.cc +++ b/src/main/cpp/util/file_windows.cc @@ -993,37 +993,14 @@ bool ChangeDirectory(const string& path) { return true; } +#ifdef COMPILER_MSVC void ForEachDirectoryEntry(const string &path, DirectoryEntryConsumer *consume) { - wstring wpath; - if (path.empty() || IsDevNull(path)) { - return; - } - if (!AsWindowsPath(path, &wpath)) { - pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, - "ForEachDirectoryEntry(%s): AsWindowsPath failed", path.c_str()); - } - - static const wstring kDot(L"."); - static const wstring kDotDot(L".."); - - wpath = L"\\\\?\\" + wpath + L"\\"; - WIN32_FIND_DATAW metadata; - windows_util::AutoHandle handle( - FindFirstFileW((wpath + L"*").c_str(), &metadata)); - if (handle.handle == INVALID_HANDLE_VALUE) { - return; // directory does not exist or is empty - } - - do { - if (kDot != metadata.cFileName && kDotDot != metadata.cFileName) { - wstring wname = wpath + metadata.cFileName; - string name(WstringToCstring(/* omit prefix */ 4 + wname.c_str()).get()); - bool is_dir = (metadata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; - consume->Consume(name, is_dir); - } - } while (FindNextFileW(handle.handle, &metadata)); + // TODO(bazel-team): implement this. + pdie(255, "blaze_util::ForEachDirectoryEntry is not implemented on Windows"); } +#else // not COMPILER_MSVC +#endif // COMPILER_MSVC string NormalizeWindowsPath(string path) { if (path.empty()) { |