Skip to content

Commit

Permalink
Deflake directory iterator for windows (#24469)
Browse files Browse the repository at this point in the history
Signed-off-by: Raven Black <ravenblack@dropbox.com>
  • Loading branch information
ravenblackx committed Dec 9, 2022
1 parent ceca213 commit c99a89c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/common/filesystem/win32/directory_iterator_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ DirectoryIteratorImpl& DirectoryIteratorImpl::operator++() {
}

DirectoryEntry DirectoryIteratorImpl::makeEntry(const WIN32_FIND_DATA& find_data) {
// `IO_REPARSE_FLAG_SYMLINK` must only be used in conjunction with
// `FILE_ATTRIBUTE_REPARSE_POINT`, per documentation for `dwReserved0` at
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataa
if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
!(find_data.dwReserved0 & IO_REPARSE_TAG_SYMLINK)) {
// The file is reparse point and not a symlink, so it can't be
// a regular file or a directory
return {std::string(find_data.cFileName), FileType::Other, absl::nullopt};
} else if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
return {std::string(find_data.cFileName), FileType::Directory, absl::nullopt};
} else if (find_data.dwReserved0 & IO_REPARSE_TAG_SYMLINK) {
} else if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) &&
(find_data.dwReserved0 & IO_REPARSE_TAG_SYMLINK)) {
return {std::string(find_data.cFileName), FileType::Regular, absl::nullopt};
} else {
ULARGE_INTEGER file_size;
Expand Down

0 comments on commit c99a89c

Please sign in to comment.