diff --git a/src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs b/src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs
index a3b63226f060c6..56fb1f8c4cdb30 100644
--- a/src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs
+++ b/src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs
@@ -43,7 +43,7 @@ internal TarEntry() { }
public int Gid { get { throw null; } set { } }
public long Length { get { throw null; } }
public string LinkName { get { throw null; } set { } }
- public System.Formats.Tar.TarFileMode Mode { get { throw null; } set { } }
+ public System.IO.UnixFileMode Mode { get { throw null; } set { } }
public System.DateTimeOffset ModificationTime { get { throw null; } set { } }
public string Name { get { throw null; } set { } }
public int Uid { get { throw null; } set { } }
@@ -86,23 +86,6 @@ public static void CreateFromDirectory(string sourceDirectoryName, string destin
public static void ExtractToDirectory(System.IO.Stream source, string destinationDirectoryName, bool overwriteFiles) { }
public static void ExtractToDirectory(string sourceFileName, string destinationDirectoryName, bool overwriteFiles) { }
}
- [System.FlagsAttribute]
- public enum TarFileMode
- {
- None = 0,
- OtherExecute = 1,
- OtherWrite = 2,
- OtherRead = 4,
- GroupExecute = 8,
- GroupWrite = 16,
- GroupRead = 32,
- UserExecute = 64,
- UserWrite = 128,
- UserRead = 256,
- StickyBit = 512,
- GroupSpecial = 1024,
- UserSpecial = 2048,
- }
public sealed partial class TarReader : System.IDisposable
{
public TarReader(System.IO.Stream archiveStream, bool leaveOpen = false) { }
diff --git a/src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj b/src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj
index f6f39c8cd98532..7d122684fcef9f 100644
--- a/src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj
+++ b/src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj
@@ -14,7 +14,6 @@
-
diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
index cb811686c54e81..3347700db32aad 100644
--- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
+++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntry.cs
@@ -162,9 +162,9 @@ public string LinkName
/// Represents the Unix file permissions of the file represented by this entry.
///
/// The value in this field has no effect on Windows platforms.
- public TarFileMode Mode
+ public UnixFileMode Mode
{
- get => (TarFileMode)_header._mode;
+ get => (UnixFileMode)_header._mode;
set
{
if ((int)value is < 0 or > 4095) // 4095 in decimal is 7777 in octal
diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFileMode.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFileMode.cs
deleted file mode 100644
index 2f0dce07e26b80..00000000000000
--- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFileMode.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Formats.Tar
-{
- ///
- /// Represents the Unix-like filesystem permissions or access modes.
- /// This enumeration supports a bitwise combination of its member values.
- ///
- [Flags]
- public enum TarFileMode
- {
- ///
- /// No permissions.
- ///
- None = 0,
- ///
- /// Execute permission for others.
- ///
- OtherExecute = 1,
- ///
- /// Write permission for others.
- ///
- OtherWrite = 2,
- ///
- /// Read permission for others.
- ///
- OtherRead = 4,
- ///
- /// Execute permission for group.
- ///
- GroupExecute = 8,
- ///
- /// Write permission for group.
- ///
- GroupWrite = 16,
- ///
- /// Read permission for group.
- ///
- GroupRead = 32,
- ///
- /// Execute permission for user.
- ///
- UserExecute = 64,
- ///
- /// Write permission for user.
- ///
- UserWrite = 128,
- ///
- /// Read permission for user.
- ///
- UserRead = 256,
- ///
- /// Sticky bit special permission.
- ///
- StickyBit = 512,
- ///
- /// Group special permission or setgid.
- ///
- GroupSpecial = 1024,
- ///
- /// User special permission o setuid.
- ///
- UserSpecial = 2048,
- }
-}
diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.cs
index 62bc6250f85d57..0f4640d42143bc 100644
--- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.cs
+++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHelpers.cs
@@ -20,8 +20,8 @@ internal static class TarHelpers
internal const byte EqualsChar = 0x3d;
internal const byte NewLineChar = 0xa;
- internal const TarFileMode DefaultMode = // 644 in octal
- TarFileMode.UserRead | TarFileMode.UserWrite | TarFileMode.GroupRead | TarFileMode.OtherRead;
+ internal const UnixFileMode DefaultMode = // 644 in octal
+ UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead | UnixFileMode.OtherRead;
// Helps advance the stream a total number of bytes larger than int.MaxValue.
internal static void AdvanceStream(Stream archiveStream, long bytesToDiscard)
diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Windows.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Windows.cs
index c3f5a6ca7a136e..906a292ac161c0 100644
--- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Windows.cs
+++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Windows.cs
@@ -10,7 +10,7 @@ namespace System.Formats.Tar
public sealed partial class TarWriter : IDisposable
{
// Creating archives in Windows always sets the mode to 777
- private const TarFileMode DefaultWindowsMode = TarFileMode.UserRead | TarFileMode.UserWrite | TarFileMode.UserExecute | TarFileMode.GroupRead | TarFileMode.GroupWrite | TarFileMode.GroupExecute | TarFileMode.OtherRead | TarFileMode.OtherWrite | TarFileMode.UserExecute;
+ private const UnixFileMode DefaultWindowsMode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute | UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute | UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.UserExecute;
// Windows specific implementation of the method that reads an entry from disk and writes it into the archive stream.
partial void ReadFileFromDiskAndWriteToArchiveStreamAsEntry(string fullPath, string entryName)
diff --git a/src/libraries/System.Formats.Tar/tests/TarTestsBase.cs b/src/libraries/System.Formats.Tar/tests/TarTestsBase.cs
index 27998a5e634ab4..868f826733a811 100644
--- a/src/libraries/System.Formats.Tar/tests/TarTestsBase.cs
+++ b/src/libraries/System.Formats.Tar/tests/TarTestsBase.cs
@@ -12,8 +12,8 @@ public abstract partial class TarTestsBase : FileCleanupTestBase
protected readonly string ModifiedEntryName = "ModifiedEntryName.ext";
// Default values are what a TarEntry created with its constructor will set
- protected const TarFileMode DefaultMode = TarFileMode.UserRead | TarFileMode.UserWrite | TarFileMode.GroupRead | TarFileMode.OtherRead; // 644 in octal, internally used as default
- protected const TarFileMode DefaultWindowsMode = TarFileMode.UserRead | TarFileMode.UserWrite | TarFileMode.UserExecute | TarFileMode.GroupRead | TarFileMode.GroupWrite | TarFileMode.GroupExecute | TarFileMode.OtherRead | TarFileMode.OtherWrite | TarFileMode.UserExecute; // Creating archives in Windows always sets the mode to 777
+ protected const UnixFileMode DefaultMode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead | UnixFileMode.OtherRead; // 644 in octal, internally used as default
+ protected const UnixFileMode DefaultWindowsMode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute | UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute | UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.UserExecute; // Creating archives in Windows always sets the mode to 777
protected const int DefaultGid = 0;
protected const int DefaultUid = 0;
protected const int DefaultDeviceMajor = 0;
@@ -36,7 +36,7 @@ public abstract partial class TarTestsBase : FileCleanupTestBase
protected readonly DateTimeOffset TestChangeTime = new DateTimeOffset(2022, 4, 4, 4, 4, 4, TimeSpan.Zero);
protected readonly string TestLinkName = "TestLinkName";
- protected const TarFileMode TestMode = TarFileMode.UserRead | TarFileMode.UserWrite | TarFileMode.GroupRead | TarFileMode.GroupWrite | TarFileMode.OtherRead | TarFileMode.OtherWrite;
+ protected const UnixFileMode TestMode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.OtherRead | UnixFileMode.OtherWrite;
protected const string TestGName = "group";
protected const string TestUName = "user";
@@ -50,9 +50,9 @@ public abstract partial class TarTestsBase : FileCleanupTestBase
protected const int AssetBlockDeviceMinor = 53;
protected const int AssetCharacterDeviceMajor = 49;
protected const int AssetCharacterDeviceMinor = 86;
- protected const TarFileMode AssetMode = TarFileMode.UserRead | TarFileMode.UserWrite | TarFileMode.UserExecute | TarFileMode.GroupRead | TarFileMode.OtherRead;
- protected const TarFileMode AssetSpecialFileMode = TarFileMode.UserRead | TarFileMode.UserWrite | TarFileMode.GroupRead | TarFileMode.OtherRead;
- protected const TarFileMode AssetSymbolicLinkMode = TarFileMode.OtherExecute | TarFileMode.OtherWrite | TarFileMode.OtherRead | TarFileMode.GroupExecute | TarFileMode.GroupWrite | TarFileMode.GroupRead | TarFileMode.UserExecute | TarFileMode.UserWrite | TarFileMode.UserRead;
+ protected const UnixFileMode AssetMode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute | UnixFileMode.GroupRead | UnixFileMode.OtherRead;
+ protected const UnixFileMode AssetSpecialFileMode = UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.GroupRead | UnixFileMode.OtherRead;
+ protected const UnixFileMode AssetSymbolicLinkMode = UnixFileMode.OtherExecute | UnixFileMode.OtherWrite | UnixFileMode.OtherRead | UnixFileMode.GroupExecute | UnixFileMode.GroupWrite | UnixFileMode.GroupRead | UnixFileMode.UserExecute | UnixFileMode.UserWrite | UnixFileMode.UserRead;
protected const string AssetGName = "devdiv";
protected const string AssetUName = "dotnet";
protected const string AssetPaxGeaKey = "globexthdr.MyGlobalExtendedAttribute";
diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs
index d35ead5a201938..b1fe162537a31a 100644
--- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs
+++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs
@@ -169,7 +169,7 @@ partial void VerifyPlatformSpecificMetadata(string filePath, TarEntry entry)
if (entry.EntryType is not TarEntryType.Directory)
{
- TarFileMode expectedMode = (TarFileMode)(status.Mode & 4095); // First 12 bits
+ UnixFileMode expectedMode = (UnixFileMode)(status.Mode & 4095); // First 12 bits
Assert.Equal(expectedMode, entry.Mode);
Assert.True(entry.ModificationTime > DateTimeOffset.UnixEpoch);