Skip to content

Commit

Permalink
No need to soft retrieve hidden and read-only in FileSystemEntry.Init…
Browse files Browse the repository at this point in the history
…ialize if in AttributesToSkip we are going to retrieve it anyway with a disk hit. Only in the case of DT_UNKNOWN, we will pre-retrieve the file cache, but we only need it when ShouldSkip is checked, and in that case, we won't have a disk hit.
  • Loading branch information
carlossanlop authored and carlossanlop committed May 7, 2021
1 parent c40386c commit 1d96271
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ internal static FileAttributes Initialize(
attributes |= FileAttributes.ReparsePoint;
if (isDirectory)
attributes |= FileAttributes.Directory;
if ((directoryEntry.NameLength > 0 && directoryEntry.Name[0] == '.') || entry._status.HasHiddenFlag) // soft retrieval
attributes |= FileAttributes.Hidden;
if (entry._status.HasReadOnlyFlag) // soft retrieval
attributes |= FileAttributes.ReadOnly;

return attributes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public bool MoveNext()
ref entry, _entry, _currentPath, _rootDirectory, _originalRootDirectory, new Span<char>(_pathBuffer));
bool isDirectory = (attributes & FileAttributes.Directory) != 0;
bool isSymlink = (attributes & FileAttributes.ReparsePoint) != 0;
bool isHidden = (attributes & FileAttributes.Hidden) != 0;
bool isReadOnly = (attributes & FileAttributes.ReadOnly) != 0;

bool isSpecialDirectory = false;
if (isDirectory)
Expand All @@ -137,8 +135,8 @@ public bool MoveNext()
// initialized yet and we could not soft-retrieve the attributes in Initialize
if ((ShouldSkip(FileAttributes.Directory) && isDirectory) ||
(ShouldSkip(FileAttributes.ReparsePoint) && isSymlink) ||
(ShouldSkip(FileAttributes.Hidden) && (isHidden || entry.IsHidden)) ||
(ShouldSkip(FileAttributes.ReadOnly) && (isReadOnly || entry.IsReadOnly)))
(ShouldSkip(FileAttributes.Hidden) && entry.IsHidden) ||
(ShouldSkip(FileAttributes.ReadOnly) && entry.IsReadOnly))
{
continue;
}
Expand Down

0 comments on commit 1d96271

Please sign in to comment.