Skip to content

Commit

Permalink
Add FileAttributes.None
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Jul 19, 2023
1 parent 420dd4e commit e0cb740
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class FileAttributesTests
[Fact]
public static void ValueTest()
{
Assert.Equal(0x0000, (int)FileAttributes.None);
Assert.Equal(0x0001, (int)FileAttributes.ReadOnly);
Assert.Equal(0x0002, (int)FileAttributes.Hidden);
Assert.Equal(0x0004, (int)FileAttributes.System);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override FileAttributes GetAttributes(string path)
using SafeFileHandle fileHandle = OpenFileHandle(path, FileAccess.Read);
return File.GetAttributes(fileHandle);
}

protected override void SetAttributes(string path, FileAttributes attributes)
{
using SafeFileHandle fileHandle = OpenFileHandle(path, FileAccess.ReadWrite);
Expand All @@ -33,7 +33,7 @@ protected override void SetAttributes(string path, FileAttributes attributes)
public void NullArgumentValidation()
{
Assert.Throws<ArgumentNullException>("fileHandle", static () => File.GetAttributes(default(SafeFileHandle)!));
Assert.Throws<ArgumentNullException>("fileHandle", static () => File.SetAttributes(default(SafeFileHandle)!, (FileAttributes)0));
Assert.Throws<ArgumentNullException>("fileHandle", static () => File.SetAttributes(default(SafeFileHandle)!, FileAttributes.None));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public bool MoveNext()
}
}

if (!isSpecialDirectory && _options.AttributesToSkip != 0)
if (!isSpecialDirectory && _options.AttributesToSkip != FileAttributes.None)
{
// entry.IsHidden and entry.IsReadOnly will hit the disk if the caches had not been
// initialized yet and we could not soft-retrieve the attributes in Initialize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace System.IO
[Flags]
public enum FileAttributes
{
None = 0x0000,
ReadOnly = 0x0001,
Hidden = 0x0002,
System = 0x0004,
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9746,6 +9746,7 @@ public enum FileAccess
[System.FlagsAttribute]
public enum FileAttributes
{
None = 0,
ReadOnly = 1,
Hidden = 2,
System = 4,
Expand Down Expand Up @@ -11320,7 +11321,7 @@ internal ConstructorInvoker() { }
public object? Invoke(object? arg1, object? arg2, object? arg3) { throw null; }
public object? Invoke(object? arg1, object? arg2, object? arg3, object? arg4) { throw null; }
public static System.Reflection.ConstructorInvoker Create(System.Reflection.ConstructorInfo constructor) { throw null; }
}
}
public partial class CustomAttributeData
{
protected CustomAttributeData() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ public void ConvertFileAttributes(bool useGenericVariant)
options);
Assert.Equal(@"""directory, compressed, integrity_stream""", json);

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

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

0 comments on commit e0cb740

Please sign in to comment.