Skip to content

Commit

Permalink
Combine FileSystemEntry.IsHidden dot check with flag check.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossanlop committed Jan 22, 2021
1 parent 75552fe commit 62b77b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,22 @@ namespace System.IO.Enumeration

FileAttributes attributes = default;
if (isSymlink)
{
attributes |= FileAttributes.ReparsePoint;
}
if (isDirectory)
{
attributes |= FileAttributes.Directory;
if (directoryEntry.Name[0] == '.')
}
if (entry.IsHidden)
{
attributes |= FileAttributes.Hidden;
}

if (attributes == default)
{
attributes = FileAttributes.Normal;
}

entry._initialAttributes = attributes;
return attributes;
Expand Down Expand Up @@ -145,7 +153,9 @@ public FileAttributes Attributes
public DateTimeOffset LastAccessTimeUtc => _status.GetLastAccessTime(FullPath, continueOnError: true);
public DateTimeOffset LastWriteTimeUtc => _status.GetLastWriteTime(FullPath, continueOnError: true);
public bool IsDirectory => _status.InitiallyDirectory;
public bool IsHidden => _directoryEntry.Name[0] == '.';
public bool IsHidden =>
(_directoryEntry.NameLength > 0 && _directoryEntry.Name[0] == '.') ||
(_status.IsMainCacheValid && _status.HasHiddenFlag);

public FileSystemInfo ToFileSystemInfo()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal struct FileStatus

// Checks if the main path (without following symbolic links) has the hidden attribute
// Only call if Refresh has been successfully called at least once
private bool HasHiddenFlag =>
internal bool HasHiddenFlag =>
(_mainCache.UserFlags & (uint)Interop.Sys.UserFlags.UF_HIDDEN) == (uint)Interop.Sys.UserFlags.UF_HIDDEN;

// Checks if the main path (without following symbolic links) has the read-only attribute
Expand Down

0 comments on commit 62b77b8

Please sign in to comment.