Skip to content

Commit 23f7dbd

Browse files
authored
Add FileAttributes.None (#89130)
1 parent b7a1b42 commit 23f7dbd

File tree

6 files changed

+8
-5
lines changed

6 files changed

+8
-5
lines changed

src/libraries/System.IO.FileSystem.Primitives/tests/FileAttributesTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public static class FileAttributesTests
1111
[Fact]
1212
public static void ValueTest()
1313
{
14+
Assert.Equal(0x0000, (int)FileAttributes.None);
1415
Assert.Equal(0x0001, (int)FileAttributes.ReadOnly);
1516
Assert.Equal(0x0002, (int)FileAttributes.Hidden);
1617
Assert.Equal(0x0004, (int)FileAttributes.System);

src/libraries/System.IO.FileSystem/tests/File/GetSetAttributes_SafeFileHandle.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected override FileAttributes GetAttributes(string path)
2222
using SafeFileHandle fileHandle = OpenFileHandle(path, FileAccess.Read);
2323
return File.GetAttributes(fileHandle);
2424
}
25-
25+
2626
protected override void SetAttributes(string path, FileAttributes attributes)
2727
{
2828
using SafeFileHandle fileHandle = OpenFileHandle(path, FileAccess.ReadWrite);
@@ -33,7 +33,7 @@ protected override void SetAttributes(string path, FileAttributes attributes)
3333
public void NullArgumentValidation()
3434
{
3535
Assert.Throws<ArgumentNullException>("fileHandle", static () => File.GetAttributes(default(SafeFileHandle)!));
36-
Assert.Throws<ArgumentNullException>("fileHandle", static () => File.SetAttributes(default(SafeFileHandle)!, (FileAttributes)0));
36+
Assert.Throws<ArgumentNullException>("fileHandle", static () => File.SetAttributes(default(SafeFileHandle)!, FileAttributes.None));
3737
}
3838
}
3939
}

src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public bool MoveNext()
129129
}
130130
}
131131

132-
if (!isSpecialDirectory && _options.AttributesToSkip != 0)
132+
if (!isSpecialDirectory && _options.AttributesToSkip != FileAttributes.None)
133133
{
134134
// entry.IsHidden and entry.IsReadOnly will hit the disk if the caches had not been
135135
// initialized yet and we could not soft-retrieve the attributes in Initialize

src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace System.IO
66
[Flags]
77
public enum FileAttributes
88
{
9+
None = 0x0000,
910
ReadOnly = 0x0001,
1011
Hidden = 0x0002,
1112
System = 0x0004,

src/libraries/System.Runtime/ref/System.Runtime.cs

+1
Original file line numberDiff line numberDiff line change
@@ -9746,6 +9746,7 @@ public enum FileAccess
97469746
[System.FlagsAttribute]
97479747
public enum FileAttributes
97489748
{
9749+
None = 0,
97499750
ReadOnly = 1,
97509751
Hidden = 2,
97519752
System = 4,

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/EnumConverterTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ public void ConvertFileAttributes(bool useGenericVariant)
186186
options);
187187
Assert.Equal(@"""directory, compressed, integrity_stream""", json);
188188

189-
json = JsonSerializer.Serialize(FileAttributes.Compressed & FileAttributes.Device, options);
190-
Assert.Equal(@"0", json);
189+
json = JsonSerializer.Serialize((FileAttributes)(-1), options);
190+
Assert.Equal(@"-1", json);
191191

192192
json = JsonSerializer.Serialize(FileAttributes.Directory & FileAttributes.Compressed | FileAttributes.IntegrityStream, options);
193193
Assert.Equal(@"""integrity_stream""", json);

0 commit comments

Comments
 (0)