Description
Comes from PowerShell/PowerShell#12834 where custom file enumerator is replaced with .Net FileSystemEnumerator.
Expectation is that:
- FileSystemEntry.Attributes property works the same as FileSystemInfo.Attributes property for Hidden (and perhaps ReadOnly) flags.
- For Extended Unix flags and Windows Reparse points we need new property FileSystemInfo.ExtendedAttributes.
It turns out the first has a simplified implementation
|
entry._status = default; |
|
FileStatus.Initialize(ref entry._status, isDirectory); |
|
|
|
FileAttributes attributes = default; |
|
if (isSymlink) |
|
attributes |= FileAttributes.ReparsePoint; |
|
if (isDirectory) |
|
attributes |= FileAttributes.Directory; |
|
if (directoryEntry.Name[0] == '.') |
|
attributes |= FileAttributes.Hidden; |
|
|
|
if (attributes == default) |
|
attributes = FileAttributes.Normal; |
|
|
|
entry._initialAttributes = attributes; |
|
return attributes; |
than the second
|
FileAttributes attributes = default; |
|
|
|
if (IsReadOnly(path)) |
|
attributes |= FileAttributes.ReadOnly; |
|
|
|
if ((_fileStatus.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFLNK) |
|
attributes |= FileAttributes.ReparsePoint; |
|
|
|
if (_isDirectory) |
|
attributes |= FileAttributes.Directory; |
|
|
|
// If the filename starts with a period or has UF_HIDDEN flag set, it's hidden. |
|
if (fileName.Length > 0 && (fileName[0] == '.' || (_fileStatus.UserFlags & (uint)Interop.Sys.UserFlags.UF_HIDDEN) == (uint)Interop.Sys.UserFlags.UF_HIDDEN)) |
|
attributes |= FileAttributes.Hidden; |
|
|
|
return attributes != default ? attributes : FileAttributes.Normal; |
Also CHFLAGS works only on BSD-like systems (MacOS, FreeBSD) but not on Linux. So expectation is that assigning Hidden flag on Linux throws PlatformNotSupportedException - it was very amazing to discover that some PowerShell tests are passed on Linux but really Hidden flag does not work.
Description
Comes from PowerShell/PowerShell#12834 where custom file enumerator is replaced with .Net FileSystemEnumerator.
Expectation is that:
It turns out the first has a simplified implementation
runtime/src/libraries/System.IO.FileSystem/src/System/IO/Enumeration/FileSystemEntry.Unix.cs
Lines 69 to 84 in bd6cbe3
than the second
runtime/src/libraries/System.IO.FileSystem/src/System/IO/FileStatus.Unix.cs
Lines 76 to 91 in bd6cbe3
Also CHFLAGS works only on BSD-like systems (MacOS, FreeBSD) but not on Linux. So expectation is that assigning Hidden flag on Linux throws PlatformNotSupportedException - it was very amazing to discover that some PowerShell tests are passed on Linux but really Hidden flag does not work.