From 09454bdb236cf470fccbd586d5b5f5d869c678bd Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Mon, 6 Jun 2022 15:39:46 -0700 Subject: [PATCH 1/3] ref: Rename TarFormat to TarEntryFormat --- .../ref/System.Formats.Tar.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 642433227b1cd2..702b5ee604d5e8 100644 --- a/src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs +++ b/src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs @@ -42,6 +42,14 @@ internal TarEntry() { } public void ExtractToFile(string destinationFileName, bool overwrite) { } public override string ToString() { throw null; } } + public enum TarEntryFormat + { + Unknown = 0, + V7 = 1, + Ustar = 2, + Pax = 3, + Gnu = 4, + } public enum TarEntryType : byte { V7RegularFile = (byte)0, @@ -87,18 +95,10 @@ public enum TarFileMode GroupSpecial = 1024, UserSpecial = 2048, } - public enum TarFormat - { - Unknown = 0, - V7 = 1, - Ustar = 2, - Pax = 3, - Gnu = 4, - } public sealed partial class TarReader : System.IDisposable { public TarReader(System.IO.Stream archiveStream, bool leaveOpen = false) { } - public System.Formats.Tar.TarFormat Format { get { throw null; } } + public System.Formats.Tar.TarEntryFormat Format { get { throw null; } } public System.Collections.Generic.IReadOnlyDictionary? GlobalExtendedAttributes { get { throw null; } } public void Dispose() { } public System.Formats.Tar.TarEntry? GetNextEntry(bool copyData = false) { throw null; } @@ -106,8 +106,8 @@ public void Dispose() { } public sealed partial class TarWriter : System.IDisposable { public TarWriter(System.IO.Stream archiveStream, System.Collections.Generic.IEnumerable>? globalExtendedAttributes = null, bool leaveOpen = false) { } - public TarWriter(System.IO.Stream archiveStream, System.Formats.Tar.TarFormat archiveFormat, bool leaveOpen = false) { } - public System.Formats.Tar.TarFormat Format { get { throw null; } } + public TarWriter(System.IO.Stream archiveStream, System.Formats.Tar.TarEntryFormat archiveFormat, bool leaveOpen = false) { } + public System.Formats.Tar.TarEntryFormat Format { get { throw null; } } public void Dispose() { } public void WriteEntry(System.Formats.Tar.TarEntry entry) { } public void WriteEntry(string fileName, string? entryName) { } From c592ec2128815e581e0034096c85e50bfaa16194 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Mon, 6 Jun 2022 15:41:02 -0700 Subject: [PATCH 2/3] src: Rename TarFormat to TarEntryFormat --- .../src/System.Formats.Tar.csproj | 2 +- .../src/System/Formats/Tar/GnuTarEntry.cs | 4 +- .../src/System/Formats/Tar/PaxTarEntry.cs | 4 +- .../src/System/Formats/Tar/PosixTarEntry.cs | 6 +-- .../src/System/Formats/Tar/TarEntry.cs | 8 ++-- .../Tar/{TarFormat.cs => TarEntryFormat.cs} | 14 +++---- .../src/System/Formats/Tar/TarEntryType.cs | 16 ++++---- .../src/System/Formats/Tar/TarFile.cs | 2 +- .../src/System/Formats/Tar/TarHeader.Read.cs | 32 ++++++++-------- .../src/System/Formats/Tar/TarHeader.Write.cs | 12 +++--- .../src/System/Formats/Tar/TarHeader.cs | 2 +- .../src/System/Formats/Tar/TarHelpers.cs | 12 +++--- .../src/System/Formats/Tar/TarReader.cs | 32 ++++++++-------- .../src/System/Formats/Tar/TarWriter.Unix.cs | 10 ++--- .../System/Formats/Tar/TarWriter.Windows.cs | 10 ++--- .../src/System/Formats/Tar/TarWriter.cs | 38 +++++++++---------- .../src/System/Formats/Tar/UstarTarEntry.cs | 2 +- .../src/System/Formats/Tar/V7TarEntry.cs | 2 +- 18 files changed, 104 insertions(+), 104 deletions(-) rename src/libraries/System.Formats.Tar/src/System/Formats/Tar/{TarFormat.cs => TarEntryFormat.cs} (57%) 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 d866dc3e3f96ca..65aa346b4907f7 100644 --- a/src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj +++ b/src/libraries/System.Formats.Tar/src/System.Formats.Tar.csproj @@ -21,12 +21,12 @@ + - diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/GnuTarEntry.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/GnuTarEntry.cs index 252a95fe378fe9..af01516d88af8c 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/GnuTarEntry.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/GnuTarEntry.cs @@ -6,7 +6,7 @@ namespace System.Formats.Tar /// /// Represents a tar entry from an archive of the GNU format. /// - /// Even though the format is not POSIX compatible, it implements and supports the Unix-specific fields that were defined in the POSIX IEEE P1003.1 standard from 1988: devmajor, devminor, gname and uname. + /// Even though the format is not POSIX compatible, it implements and supports the Unix-specific fields that were defined in the POSIX IEEE P1003.1 standard from 1988: devmajor, devminor, gname and uname. public sealed class GnuTarEntry : PosixTarEntry { // Constructor used when reading an existing archive. @@ -29,7 +29,7 @@ internal GnuTarEntry(TarHeader header, TarReader readerOfOrigin) /// /// public GnuTarEntry(TarEntryType entryType, string entryName) - : base(entryType, entryName, TarFormat.Gnu) + : base(entryType, entryName, TarEntryFormat.Gnu) { } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PaxTarEntry.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PaxTarEntry.cs index 54b44f71a55b23..fc5b9c3dbeeae3 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PaxTarEntry.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PaxTarEntry.cs @@ -50,7 +50,7 @@ internal PaxTarEntry(TarHeader header, TarReader readerOfOrigin) /// /// public PaxTarEntry(TarEntryType entryType, string entryName) - : base(entryType, entryName, TarFormat.Pax) + : base(entryType, entryName, TarEntryFormat.Pax) { } @@ -84,7 +84,7 @@ public PaxTarEntry(TarEntryType entryType, string entryName) /// /// public PaxTarEntry(TarEntryType entryType, string entryName, IEnumerable> extendedAttributes) - : base(entryType, entryName, TarFormat.Pax) + : base(entryType, entryName, TarEntryFormat.Pax) { ArgumentNullException.ThrowIfNull(extendedAttributes); _header.ReplaceNormalAttributesWithExtended(extendedAttributes); diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PosixTarEntry.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PosixTarEntry.cs index 0b682454f38706..c3d8394ea8fefe 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PosixTarEntry.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/PosixTarEntry.cs @@ -4,10 +4,10 @@ namespace System.Formats.Tar { /// - /// Abstract class that represents a tar entry from an archive of a format that is based on the POSIX IEEE P1003.1 standard from 1988. This includes the formats (represented by the class), (represented by the class) and (represented by the class). + /// Abstract class that represents a tar entry from an archive of a format that is based on the POSIX IEEE P1003.1 standard from 1988. This includes the formats (represented by the class), (represented by the class) and (represented by the class). /// /// Formats that implement the POSIX IEEE P1003.1 standard from 1988, support the following header fields: devmajor, devminor, gname and uname. - /// Even though the format is not POSIX compatible, it implements and supports the Unix-specific fields that were defined in that POSIX standard. + /// Even though the format is not POSIX compatible, it implements and supports the Unix-specific fields that were defined in that POSIX standard. public abstract partial class PosixTarEntry : TarEntry { // Constructor used when reading an existing archive. @@ -17,7 +17,7 @@ internal PosixTarEntry(TarHeader header, TarReader readerOfOrigin) } // Constructor called when creating a new 'TarEntry*' instance that can be passed to a TarWriter. - internal PosixTarEntry(TarEntryType entryType, string entryName, TarFormat format) + internal PosixTarEntry(TarEntryType entryType, string entryName, TarEntryFormat format) : base(entryType, entryName, format) { } 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 ce5e076cfc38ae..a2328ea9691a3c 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 @@ -11,7 +11,7 @@ namespace System.Formats.Tar /// /// Abstract class that represents a tar entry from an archive. /// - /// All the properties exposed by this class are supported by the , , and formats. + /// All the properties exposed by this class are supported by the , , and formats. public abstract partial class TarEntry { internal TarHeader _header; @@ -26,7 +26,7 @@ internal TarEntry(TarHeader header, TarReader readerOfOrigin) } // Constructor called when creating a new 'TarEntry*' instance that can be passed to a TarWriter. - internal TarEntry(TarEntryType entryType, string entryName, TarFormat format) + internal TarEntry(TarEntryType entryType, string entryName, TarEntryFormat format) { ArgumentException.ThrowIfNullOrEmpty(entryName); @@ -93,7 +93,7 @@ public DateTimeOffset ModificationTime /// /// When the indicates an entry that can contain data, this property returns the length in bytes of such data. /// - /// The entry type that commonly contains data is (or in the format). Other uncommon entry types that can also contain data are: , , and . + /// The entry type that commonly contains data is (or in the format). Other uncommon entry types that can also contain data are: , , and . public long Length => _header._dataStream != null ? _header._dataStream.Length : _header._size; /// @@ -211,7 +211,7 @@ public void ExtractToFile(string destinationFileName, bool overwrite) /// Gets a stream that represents the data section of this entry. /// Sets a new stream that represents the data section, if it makes sense for the to contain data; if a stream already existed, the old stream gets disposed before substituting it with the new stream. Setting a stream is allowed. /// If you write data to this data stream, make sure to rewind it to the desired start position before writing this entry into an archive using . - /// Setting a data section is not supported because the is not (or for an archive of format). + /// Setting a data section is not supported because the is not (or for an archive of format). /// Cannot set an unreadable stream. /// -or- /// An I/O problem occurred. diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFormat.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntryFormat.cs similarity index 57% rename from src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFormat.cs rename to src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntryFormat.cs index 1f4bd40327ff84..e215dcbff313f5 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFormat.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntryFormat.cs @@ -4,28 +4,28 @@ namespace System.Formats.Tar { /// - /// Specifies the supported Tar formats. + /// Specifies the supported formats that tar entries can use. /// - public enum TarFormat + public enum TarEntryFormat { /// - /// Tar format undetermined. + /// Tar entry format undetermined. /// Unknown, /// - /// 1979 Version 7 AT&T Unix Tar Command Format (v7). + /// 1979 Version 7 AT&T Unix tar entry format. /// V7, /// - /// POSIX IEEE 1003.1-1988 Unix Standard Tar Format (ustar). + /// POSIX IEEE 1003.1-1988 Unix Standard tar entry format. /// Ustar, /// - /// POSIX IEEE 1003.1-2001 ("POSIX.1") Pax Interchange Tar Format (pax). + /// POSIX IEEE 1003.1-2001 ("POSIX.1") Pax Interchange tar entry format. /// Pax, /// - /// GNU Tar Format (gnu). + /// GNU tar entry format (gnu). /// Gnu, } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntryType.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntryType.cs index 3f3e61556eb666..b297f178fad1b7 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntryType.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarEntryType.cs @@ -11,7 +11,7 @@ public enum TarEntryType : byte { /// /// Regular file. - /// This entry type is specific to the , and formats. + /// This entry type is specific to the , and formats. /// RegularFile = (byte)'0', /// @@ -43,7 +43,7 @@ public enum TarEntryType : byte Fifo = (byte)'6', /// /// GNU contiguous file - /// This entry type is specific to the format, and is treated as a entry type. + /// This entry type is specific to the format, and is treated as a entry type. /// // According to the GNU spec, it's extremely rare to encounter a contiguous entry. ContiguousFile = (byte)'7', @@ -59,7 +59,7 @@ public enum TarEntryType : byte GlobalExtendedAttributes = (byte)'g', /// /// GNU directory with a list of entries. - /// This entry type is specific to the format, and is treated as a entry type that contains a data section. + /// This entry type is specific to the format, and is treated as a entry type that contains a data section. /// DirectoryList = (byte)'D', /// @@ -74,27 +74,27 @@ public enum TarEntryType : byte LongPath = (byte)'L', /// /// GNU multi-volume file. - /// This entry type is specific to the format and is not supported for writing. + /// This entry type is specific to the format and is not supported for writing. /// MultiVolume = (byte)'M', /// /// V7 Regular file. - /// This entry type is specific to the format. + /// This entry type is specific to the format. /// V7RegularFile = (byte)'\0', /// /// GNU file to be renamed/symlinked. - /// This entry type is specific to the format. It is considered unsafe and is ignored by other tools. + /// This entry type is specific to the format. It is considered unsafe and is ignored by other tools. /// RenamedOrSymlinked = (byte)'N', /// /// GNU sparse file. - /// This entry type is specific to the format and is not supported for writing. + /// This entry type is specific to the format and is not supported for writing. /// SparseFile = (byte)'S', /// /// GNU tape volume. - /// This entry type is specific to the format and is not supported for writing. + /// This entry type is specific to the format and is not supported for writing. /// TapeVolume = (byte)'V', } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFile.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFile.cs index ba56ac87441614..66e87920fe20df 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFile.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarFile.cs @@ -196,7 +196,7 @@ private static void CreateFromDirectoryInternal(string sourceDirectoryName, Stre Debug.Assert(Path.IsPathFullyQualified(sourceDirectoryName)); Debug.Assert(destination.CanWrite); - using (TarWriter writer = new TarWriter(destination, TarFormat.Pax, leaveOpen)) + using (TarWriter writer = new TarWriter(destination, TarEntryFormat.Pax, leaveOpen)) { bool baseDirectoryIsEmpty = true; DirectoryInfo di = new(sourceDirectoryName); diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs index 1e46719c839e93..2e92a7429e88d2 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Read.cs @@ -39,7 +39,7 @@ internal bool TryGetNextHeader(Stream archiveStream, bool copyData) // Confirms if gnu, or tentatively selects ustar ReadMagicAttribute(buffer); - if (_format != TarFormat.V7) + if (_format != TarEntryFormat.V7) { // Confirms if gnu ReadVersionAttribute(buffer); @@ -47,12 +47,12 @@ internal bool TryGetNextHeader(Stream archiveStream, bool copyData) // Fields that ustar, pax and gnu share identically ReadPosixAndGnuSharedAttributes(buffer); - Debug.Assert(_format is TarFormat.Ustar or TarFormat.Pax or TarFormat.Gnu); - if (_format == TarFormat.Ustar) + Debug.Assert(_format is TarEntryFormat.Ustar or TarEntryFormat.Pax or TarEntryFormat.Gnu); + if (_format == TarEntryFormat.Ustar) { ReadUstarAttributes(buffer); } - else if (_format == TarFormat.Gnu) + else if (_format == TarEntryFormat.Gnu) { ReadGnuAttributes(buffer); } @@ -334,12 +334,12 @@ private bool TryReadCommonAttributes(Span buffer) _typeFlag = (TarEntryType)buffer[FieldLocations.TypeFlag]; _linkName = TarHelpers.GetTrimmedUtf8String(buffer.Slice(FieldLocations.LinkName, FieldLengths.LinkName)); - if (_format == TarFormat.Unknown) + if (_format == TarEntryFormat.Unknown) { _format = _typeFlag switch { TarEntryType.ExtendedAttributes or - TarEntryType.GlobalExtendedAttributes => TarFormat.Pax, + TarEntryType.GlobalExtendedAttributes => TarEntryFormat.Pax, TarEntryType.DirectoryList or TarEntryType.LongLink or @@ -347,14 +347,14 @@ TarEntryType.LongPath or TarEntryType.MultiVolume or TarEntryType.RenamedOrSymlinked or TarEntryType.SparseFile or - TarEntryType.TapeVolume => TarFormat.Gnu, + TarEntryType.TapeVolume => TarEntryFormat.Gnu, // V7 is the only one that uses 'V7RegularFile'. - TarEntryType.V7RegularFile => TarFormat.V7, + TarEntryType.V7RegularFile => TarEntryFormat.V7, // We can quickly determine the *minimum* possible format if the entry type // is the POSIX 'RegularFile', although later we could upgrade it to PAX or GNU - _ => (_typeFlag == TarEntryType.RegularFile) ? TarFormat.Ustar : TarFormat.V7 + _ => (_typeFlag == TarEntryType.RegularFile) ? TarEntryFormat.Ustar : TarEntryFormat.V7 }; } @@ -370,7 +370,7 @@ private void ReadMagicAttribute(Span buffer) // If at this point the magic value is all nulls, we definitely have a V7 if (TarHelpers.IsAllNullBytes(magic)) { - _format = TarFormat.V7; + _format = TarEntryFormat.V7; return; } @@ -379,12 +379,12 @@ private void ReadMagicAttribute(Span buffer) if (_magic == GnuMagic) { - _format = TarFormat.Gnu; + _format = TarEntryFormat.Gnu; } - else if (_format == TarFormat.V7 && _magic == UstarMagic) + else if (_format == TarEntryFormat.V7 && _magic == UstarMagic) { // Important: Only change to ustar if we had not changed the format to pax already - _format = TarFormat.Ustar; + _format = TarEntryFormat.Ustar; } } @@ -392,7 +392,7 @@ private void ReadMagicAttribute(Span buffer) // Throws if converting the bytes to string fails or if an unexpected version string is found. private void ReadVersionAttribute(Span buffer) { - if (_format == TarFormat.V7) + if (_format == TarEntryFormat.V7) { return; } @@ -402,13 +402,13 @@ private void ReadVersionAttribute(Span buffer) _version = Encoding.ASCII.GetString(version); // The POSIX formats have a 6 byte Magic "ustar\0", followed by a 2 byte Version "00" - if ((_format is TarFormat.Ustar or TarFormat.Pax) && _version != UstarVersion) + if ((_format is TarEntryFormat.Ustar or TarEntryFormat.Pax) && _version != UstarVersion) { throw new FormatException(string.Format(SR.TarPosixFormatExpected, _name)); } // The GNU format has a Magic+Version 8 byte string "ustar \0" - if (_format == TarFormat.Gnu && _version != GnuVersion) + if (_format == TarEntryFormat.Gnu && _version != GnuVersion) { throw new FormatException(string.Format(SR.TarGnuFormatExpected, _name)); } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs index 0c2cf88c9c7e87..c82566ad98eb7d 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs @@ -48,7 +48,7 @@ internal static void WriteGlobalExtendedAttributesHeader(Stream archiveStream, S internal void WriteAsV7(Stream archiveStream, Span buffer) { long actualLength = GetTotalDataBytesToWrite(); - TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarFormat.V7); + TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarEntryFormat.V7); int checksum = WriteName(buffer, out _); checksum += WriteCommonFields(buffer, actualLength, actualEntryType); @@ -66,7 +66,7 @@ internal void WriteAsV7(Stream archiveStream, Span buffer) internal void WriteAsUstar(Stream archiveStream, Span buffer) { long actualLength = GetTotalDataBytesToWrite(); - TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarFormat.Ustar); + TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarEntryFormat.Ustar); int checksum = WritePosixName(buffer); checksum += WriteCommonFields(buffer, actualLength, actualEntryType); @@ -153,7 +153,7 @@ internal void WriteAsGnuInternal(Stream archiveStream, Span buffer) _gnuUnusedBytes ??= new byte[FieldLengths.AllGnuUnused]; long actualLength = GetTotalDataBytesToWrite(); - TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarFormat.Gnu); + TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarEntryFormat.Gnu); int checksum = WriteName(buffer, out _); checksum += WriteCommonFields(buffer, actualLength, actualEntryType); @@ -194,7 +194,7 @@ private void WriteAsPaxExtendedAttributes(Stream archiveStream, Span buffe private void WriteAsPaxInternal(Stream archiveStream, Span buffer) { long actualLength = GetTotalDataBytesToWrite(); - TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarFormat.Pax); + TarEntryType actualEntryType = GetCorrectTypeFlagForFormat(TarEntryFormat.Pax); int checksum = WritePosixName(buffer); checksum += WriteCommonFields(buffer, actualLength, actualEntryType); @@ -275,9 +275,9 @@ private int WriteCommonFields(Span buffer, long actualLength, TarEntryType // When writing an entry that came from an archive of a different format, if its entry type happens to // be an incompatible regular file entry type, convert it to the compatible one. // No change for all other entry types. - private TarEntryType GetCorrectTypeFlagForFormat(TarFormat format) + private TarEntryType GetCorrectTypeFlagForFormat(TarEntryFormat format) { - if (format is TarFormat.V7) + if (format is TarEntryFormat.V7) { if (_typeFlag is TarEntryType.RegularFile) { diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.cs index aa0bab5aae02c9..217b16efb215c5 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.cs @@ -43,7 +43,7 @@ internal partial struct TarHeader // Position in the stream where the data ends in this header. internal long _endOfHeaderAndDataAndBlockAlignment; - internal TarFormat _format; + internal TarEntryFormat _format; // Common attributes 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 db80de8ef0257e..dc0b16d77d5841 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 @@ -179,11 +179,11 @@ internal static int SkipBlockAlignmentPadding(Stream archiveStream, long size) // Throws if the specified entry type is not supported for the specified format. // If 'forWriting' is true, an incompatible 'Regular File' entry type is allowed. It will be converted to the compatible version before writing. - internal static void VerifyEntryTypeIsSupported(TarEntryType entryType, TarFormat archiveFormat, bool forWriting) + internal static void VerifyEntryTypeIsSupported(TarEntryType entryType, TarEntryFormat archiveFormat, bool forWriting) { switch (archiveFormat) { - case TarFormat.V7: + case TarEntryFormat.V7: if (entryType is TarEntryType.Directory or TarEntryType.HardLink or @@ -198,7 +198,7 @@ TarEntryType.V7RegularFile or } break; - case TarFormat.Ustar: + case TarEntryFormat.Ustar: if (entryType is TarEntryType.BlockDevice or TarEntryType.CharacterDevice or @@ -216,7 +216,7 @@ TarEntryType.RegularFile or } break; - case TarFormat.Pax: + case TarEntryFormat.Pax: if (entryType is TarEntryType.BlockDevice or TarEntryType.CharacterDevice or @@ -237,7 +237,7 @@ TarEntryType.RegularFile or } break; - case TarFormat.Gnu: + case TarEntryFormat.Gnu: if (entryType is TarEntryType.BlockDevice or TarEntryType.CharacterDevice or @@ -266,7 +266,7 @@ TarEntryType.RegularFile or } break; - case TarFormat.Unknown: + case TarEntryFormat.Unknown: default: throw new FormatException(string.Format(SR.TarInvalidFormat, archiveFormat)); } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs index 2aa5b3875d848e..3c651c63da1519 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarReader.cs @@ -41,19 +41,19 @@ public TarReader(Stream archiveStream, bool leaveOpen = false) _previouslyReadEntry = null; GlobalExtendedAttributes = null; - Format = TarFormat.Unknown; + Format = TarEntryFormat.Unknown; _isDisposed = false; _readFirstEntry = false; _reachedEndMarkers = false; } /// - /// The format of the archive. It is initially . The archive format is detected after the first call to . + /// The format of the archive. It is initially . The archive format is detected after the first call to . /// - public TarFormat Format { get; private set; } + public TarEntryFormat Format { get; private set; } /// - /// If the archive format is , returns a read-only dictionary containing the string key-value pairs of the Global Extended Attributes in the first entry of the archive. + /// If the archive format is , returns a read-only dictionary containing the string key-value pairs of the Global Extended Attributes in the first entry of the archive. /// If there is no Global Extended Attributes entry at the beginning of the archive, this returns an empty read-only dictionary. /// If the first entry has not been read by calling , this returns . /// @@ -89,9 +89,9 @@ public void Dispose() /// -or- /// The archive contains entries in different formats. /// -or- - /// More than one Global Extended Attributes Entry was found in the current archive. + /// More than one Global Extended Attributes Entry was found in the current archive. /// -or- - /// Two or more Extended Attributes entries were found consecutively in the current archive. + /// Two or more Extended Attributes entries were found consecutively in the current archive. /// An I/O problem occurred. public TarEntry? GetNextEntry(bool copyData = false) { @@ -115,7 +115,7 @@ public void Dispose() { if (!_readFirstEntry) { - Debug.Assert(Format == TarFormat.Unknown); + Debug.Assert(Format == TarEntryFormat.Unknown); Format = header._format; _readFirstEntry = true; } @@ -126,10 +126,10 @@ public void Dispose() TarEntry entry = Format switch { - TarFormat.Pax => new PaxTarEntry(header, this), - TarFormat.Gnu => new GnuTarEntry(header, this), - TarFormat.Ustar => new UstarTarEntry(header, this), - TarFormat.V7 or TarFormat.Unknown or _ => new V7TarEntry(header, this), + TarEntryFormat.Pax => new PaxTarEntry(header, this), + TarEntryFormat.Gnu => new GnuTarEntry(header, this), + TarEntryFormat.Ustar => new UstarTarEntry(header, this), + TarEntryFormat.V7 or TarEntryFormat.Unknown or _ => new V7TarEntry(header, this), }; _previouslyReadEntry = entry; @@ -250,7 +250,7 @@ private bool TryGetNextEntryHeader(out TarHeader header, bool copyData) GlobalExtendedAttributes = header._extendedAttributes?.AsReadOnly(); header = default; - header._format = TarFormat.Pax; + header._format = TarEntryFormat.Pax; try { if (!header.TryGetNextHeader(_archiveStream, copyData)) @@ -261,7 +261,7 @@ private bool TryGetNextEntryHeader(out TarHeader header, bool copyData) catch (EndOfStreamException) { // Edge case: The only entry in the archive was a Global Extended Attributes entry - Format = TarFormat.Pax; + Format = TarEntryFormat.Pax; return false; } if (header._typeFlag == TarEntryType.GlobalExtendedAttributes) @@ -308,7 +308,7 @@ private bool TryGetNextEntryHeader(out TarHeader header, bool copyData) private bool TryProcessExtendedAttributesHeader(TarHeader firstHeader, bool copyData, out TarHeader secondHeader) { secondHeader = default; - secondHeader._format = TarFormat.Pax; + secondHeader._format = TarEntryFormat.Pax; // Now get the actual entry if (!secondHeader.TryGetNextHeader(_archiveStream, copyData)) @@ -346,7 +346,7 @@ private bool TryProcessGnuMetadataHeader(TarHeader header, bool copyData, out Ta finalHeader = default; TarHeader secondHeader = default; - secondHeader._format = TarFormat.Gnu; + secondHeader._format = TarEntryFormat.Gnu; // Get the second entry, which is the actual entry if (!secondHeader.TryGetNextHeader(_archiveStream, copyData)) @@ -365,7 +365,7 @@ private bool TryProcessGnuMetadataHeader(TarHeader header, bool copyData, out Ta (header._typeFlag is TarEntryType.LongPath && secondHeader._typeFlag is TarEntryType.LongLink)) { TarHeader thirdHeader = default; - thirdHeader._format = TarFormat.Gnu; + thirdHeader._format = TarEntryFormat.Gnu; // Get the third entry, which is the actual entry if (!thirdHeader.TryGetNextHeader(_archiveStream, copyData)) diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Unix.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Unix.cs index 7fa73a3cf13cb5..8296910d386043 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Unix.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Unix.cs @@ -29,7 +29,7 @@ partial void ReadFileFromDiskAndWriteToArchiveStreamAsEntry(string fullPath, str Interop.Sys.FileTypes.S_IFCHR => TarEntryType.CharacterDevice, Interop.Sys.FileTypes.S_IFIFO => TarEntryType.Fifo, Interop.Sys.FileTypes.S_IFLNK => TarEntryType.SymbolicLink, - Interop.Sys.FileTypes.S_IFREG => Format is TarFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile, + Interop.Sys.FileTypes.S_IFREG => Format is TarEntryFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile, Interop.Sys.FileTypes.S_IFDIR => TarEntryType.Directory, _ => throw new IOException(string.Format(SR.TarUnsupportedFile, fullPath)), }; @@ -38,10 +38,10 @@ partial void ReadFileFromDiskAndWriteToArchiveStreamAsEntry(string fullPath, str TarEntry entry = Format switch { - TarFormat.V7 => new V7TarEntry(entryType, entryName), - TarFormat.Ustar => new UstarTarEntry(entryType, entryName), - TarFormat.Pax => new PaxTarEntry(entryType, entryName), - TarFormat.Gnu => new GnuTarEntry(entryType, entryName), + TarEntryFormat.V7 => new V7TarEntry(entryType, entryName), + TarEntryFormat.Ustar => new UstarTarEntry(entryType, entryName), + TarEntryFormat.Pax => new PaxTarEntry(entryType, entryName), + TarEntryFormat.Gnu => new GnuTarEntry(entryType, entryName), _ => throw new FormatException(string.Format(SR.TarInvalidFormat, Format)), }; 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 5fdd3b97d85c84..bee4ac9b7c319f 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 @@ -28,7 +28,7 @@ partial void ReadFileFromDiskAndWriteToArchiveStreamAsEntry(string fullPath, str } else if (attributes.HasFlag(FileAttributes.Normal) || attributes.HasFlag(FileAttributes.Archive)) { - entryType = Format is TarFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; + entryType = Format is TarEntryFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; } else { @@ -37,10 +37,10 @@ partial void ReadFileFromDiskAndWriteToArchiveStreamAsEntry(string fullPath, str TarEntry entry = Format switch { - TarFormat.V7 => new V7TarEntry(entryType, entryName), - TarFormat.Ustar => new UstarTarEntry(entryType, entryName), - TarFormat.Pax => new PaxTarEntry(entryType, entryName), - TarFormat.Gnu => new GnuTarEntry(entryType, entryName), + TarEntryFormat.V7 => new V7TarEntry(entryType, entryName), + TarEntryFormat.Ustar => new UstarTarEntry(entryType, entryName), + TarEntryFormat.Pax => new PaxTarEntry(entryType, entryName), + TarEntryFormat.Gnu => new GnuTarEntry(entryType, entryName), _ => throw new FormatException(string.Format(SR.TarInvalidFormat, Format)), }; diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs index 4d715cdd6b3301..ece218d02e9f4f 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs @@ -21,13 +21,13 @@ public sealed partial class TarWriter : IDisposable private readonly IEnumerable>? _globalExtendedAttributes; /// - /// Initializes a instance that can write tar entries to the specified stream, optionally leave the stream open upon disposal of this instance, and can optionally add a Global Extended Attributes entry at the beginning of the archive. When using this constructor, the format of the resulting archive is . + /// Initializes a instance that can write tar entries to the specified stream, optionally leave the stream open upon disposal of this instance, and can optionally add a Global Extended Attributes entry at the beginning of the archive. When using this constructor, the format of the resulting archive is . /// /// The stream to write to. /// An optional enumeration of string key-value pairs that represent Global Extended Attributes metadata that should apply to all subsquent entries. If , then no Global Extended Attributes entry is written. If an empty instance is passed, a Global Extended Attributes entry is written with default values. /// to dispose the when this instance is disposed; to leave the stream open. public TarWriter(Stream archiveStream, IEnumerable>? globalExtendedAttributes = null, bool leaveOpen = false) - : this(archiveStream, TarFormat.Pax, leaveOpen) + : this(archiveStream, TarEntryFormat.Pax, leaveOpen) { _globalExtendedAttributes = globalExtendedAttributes; } @@ -38,12 +38,12 @@ public TarWriter(Stream archiveStream, IEnumerable> /// The stream to write to. /// The format of the archive. /// to dispose the when this instance is disposed; to leave the stream open. - /// If the selected is , no Global Extended Attributes entry is written. To write a PAX archive with a Global Extended Attributes entry inserted at the beginning of the archive, use the constructor instead. - /// The recommended format is for its flexibility. + /// If the selected is , no Global Extended Attributes entry is written. To write a PAX archive with a Global Extended Attributes entry inserted at the beginning of the archive, use the constructor instead. + /// The recommended format is for its flexibility. /// is . /// is unwritable. - /// is either , or not one of the other enum values. - public TarWriter(Stream archiveStream, TarFormat archiveFormat, bool leaveOpen = false) + /// is either , or not one of the other enum values. + public TarWriter(Stream archiveStream, TarEntryFormat archiveFormat, bool leaveOpen = false) { ArgumentNullException.ThrowIfNull(archiveStream); @@ -52,7 +52,7 @@ public TarWriter(Stream archiveStream, TarFormat archiveFormat, bool leaveOpen = throw new IOException(SR.IO_NotSupported_UnwritableStream); } - if (archiveFormat is not TarFormat.V7 and not TarFormat.Ustar and not TarFormat.Pax and not TarFormat.Gnu) + if (archiveFormat is not TarEntryFormat.V7 and not TarEntryFormat.Ustar and not TarEntryFormat.Pax and not TarEntryFormat.Gnu) { throw new ArgumentOutOfRangeException(nameof(archiveFormat)); } @@ -69,7 +69,7 @@ public TarWriter(Stream archiveStream, TarFormat archiveFormat, bool leaveOpen = /// /// The format of the archive. /// - public TarFormat Format { get; private set; } + public TarEntryFormat Format { get; private set; } /// /// Disposes the current instance, and closes the archive stream if the leaveOpen argument was set to in the constructor. @@ -109,7 +109,7 @@ public void WriteEntry(string fileName, string? entryName) entryName = Path.GetFileName(fileName); } - if (Format is TarFormat.Pax) + if (Format is TarEntryFormat.Pax) { WriteGlobalExtendedAttributesEntryIfNeeded(); } @@ -136,7 +136,7 @@ public void WriteEntry(string fileName, string? entryName) /// These are the entry types supported for writing on each format: /// /// - /// + /// /// /// /// @@ -145,7 +145,7 @@ public void WriteEntry(string fileName, string? entryName) /// /// /// - /// , and + /// , and /// /// /// @@ -176,19 +176,19 @@ public void WriteEntry(TarEntry entry) { switch (Format) { - case TarFormat.V7: + case TarEntryFormat.V7: entry._header.WriteAsV7(_archiveStream, buffer); break; - case TarFormat.Ustar: + case TarEntryFormat.Ustar: entry._header.WriteAsUstar(_archiveStream, buffer); break; - case TarFormat.Pax: + case TarEntryFormat.Pax: entry._header.WriteAsPax(_archiveStream, buffer); break; - case TarFormat.Gnu: + case TarEntryFormat.Gnu: entry._header.WriteAsGnu(_archiveStream, buffer); break; - case TarFormat.Unknown: + case TarEntryFormat.Unknown: default: throw new FormatException(string.Format(SR.TarInvalidFormat, Format)); } @@ -210,7 +210,7 @@ public void WriteEntry(TarEntry entry) // /// These are the entry types supported for writing on each format: // /// // /// - // /// + // /// // /// // /// // /// @@ -219,7 +219,7 @@ public void WriteEntry(TarEntry entry) // /// // /// // /// - // /// , and + // /// , and // /// // /// // /// @@ -279,7 +279,7 @@ private void WriteGlobalExtendedAttributesEntryIfNeeded() { Debug.Assert(!_isDisposed); - if (_wroteGEA || Format != TarFormat.Pax) + if (_wroteGEA || Format != TarEntryFormat.Pax) { return; } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/UstarTarEntry.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/UstarTarEntry.cs index 13e1d9c358a69b..b1cbaef8b16d3f 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/UstarTarEntry.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/UstarTarEntry.cs @@ -28,7 +28,7 @@ internal UstarTarEntry(TarHeader header, TarReader readerOfOrigin) /// /// public UstarTarEntry(TarEntryType entryType, string entryName) - : base(entryType, entryName, TarFormat.Ustar) + : base(entryType, entryName, TarEntryFormat.Ustar) { } diff --git a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/V7TarEntry.cs b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/V7TarEntry.cs index 84389365c73725..6972daf20dc289 100644 --- a/src/libraries/System.Formats.Tar/src/System/Formats/Tar/V7TarEntry.cs +++ b/src/libraries/System.Formats.Tar/src/System/Formats/Tar/V7TarEntry.cs @@ -23,7 +23,7 @@ internal V7TarEntry(TarHeader header, TarReader readerOfOrigin) /// The entry type is not supported for creating an entry. /// When creating an instance using the constructor, only the following entry types are supported: , , and . public V7TarEntry(TarEntryType entryType, string entryName) - : base(entryType, entryName, TarFormat.V7) + : base(entryType, entryName, TarEntryFormat.V7) { } From db3a59dfc7cd2f44a1427626b976cbd77647be99 Mon Sep 17 00:00:00 2001 From: carlossanlop Date: Mon, 6 Jun 2022 15:41:12 -0700 Subject: [PATCH 3/3] tests: Rename TarFormat to TarEntryFormat --- .../tests/CompressedTar.Tests.cs | 4 +- ...TarFile.ExtractToDirectory.Stream.Tests.cs | 6 +- .../tests/TarReader/TarReader.File.Tests.cs | 198 +++++++++--------- .../TarReader/TarReader.GetNextEntry.Tests.cs | 10 +- .../tests/TarWriter/TarWriter.Tests.cs | 36 ++-- .../TarWriter.WriteEntry.Entry.Gnu.Tests.cs | 22 +- .../TarWriter.WriteEntry.Entry.Pax.Tests.cs | 22 +- .../TarWriter.WriteEntry.Entry.Ustar.Tests.cs | 16 +- .../TarWriter.WriteEntry.Entry.V7.Tests.cs | 26 +-- .../TarWriter.WriteEntry.File.Tests.Unix.cs | 36 ++-- .../TarWriter.WriteEntry.File.Tests.cs | 58 ++--- .../TarWriter/TarWriter.WriteEntry.Tests.cs | 2 +- 12 files changed, 218 insertions(+), 218 deletions(-) diff --git a/src/libraries/System.Formats.Tar/tests/CompressedTar.Tests.cs b/src/libraries/System.Formats.Tar/tests/CompressedTar.Tests.cs index a056bc0eed9c75..d13bf469d73afc 100644 --- a/src/libraries/System.Formats.Tar/tests/CompressedTar.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/CompressedTar.Tests.cs @@ -37,7 +37,7 @@ public void TarGz_TarWriter_TarReader() using GZipStream decompressorStream = new GZipStream(streamToDecompress, CompressionMode.Decompress); using TarReader reader = new TarReader(decompressorStream); TarEntry entry = reader.GetNextEntry(); - Assert.Equal(TarFormat.Pax, reader.Format); + Assert.Equal(TarEntryFormat.Pax, reader.Format); Assert.Equal(fileName, entry.Name); Assert.Null(reader.GetNextEntry()); } @@ -77,4 +77,4 @@ public void TarGz_TarFile_CreateFromDir_ExtractToDir() } } } -} \ No newline at end of file +} diff --git a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs index 5bb0d9b2c3eb49..8b9af8b3bc3e26 100644 --- a/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarFile/TarFile.ExtractToDirectory.Stream.Tests.cs @@ -52,7 +52,7 @@ public void ExtractEntry_ManySubfolderSegments_NoPrecedingDirectoryEntries() string fileWithTwoSegments = Path.Join(secondSegment, "c.txt"); using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { // No preceding directory entries for the segments UstarTarEntry entry = new UstarTarEntry(TarEntryType.RegularFile, fileWithTwoSegments); @@ -78,7 +78,7 @@ public void ExtractEntry_ManySubfolderSegments_NoPrecedingDirectoryEntries() public void Extract_LinkEntry_TargetOutsideDirectory(TarEntryType entryType) { using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry entry = new UstarTarEntry(entryType, "link"); entry.LinkName = PlatformDetection.IsWindows ? @"C:\Windows\System32\notepad.exe" : "/usr/bin/nano"; @@ -112,7 +112,7 @@ private void Extract_LinkEntry_TargetInsideDirectory_Internal(TarEntryType entry File.Create(targetPath).Dispose(); using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry entry = new UstarTarEntry(entryType, linkName); entry.LinkName = targetPath; diff --git a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs index ef619edb472f96..02758eba6a4f5c 100644 --- a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.File.Tests.cs @@ -12,13 +12,13 @@ namespace System.Formats.Tar.Tests public class TarReader_File_Tests : TarTestsBase { [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_File(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_File(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "file"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -32,7 +32,7 @@ public void Read_Archive_File(TarFormat format, TestTarFormat testFormat) } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry file = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -50,13 +50,13 @@ public void Read_Archive_File(TarFormat format, TestTarFormat testFormat) } [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_File_HardLink(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_File_HardLink(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "file_hardlink"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -69,7 +69,7 @@ public void Read_Archive_File_HardLink(TarFormat format, TestTarFormat testForma Assert.Null(reader.GlobalExtendedAttributes); } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry file = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -91,13 +91,13 @@ public void Read_Archive_File_HardLink(TarFormat format, TestTarFormat testForma } [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_File_SymbolicLink(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_File_SymbolicLink(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "file_symlink"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -111,7 +111,7 @@ public void Read_Archive_File_SymbolicLink(TarFormat format, TestTarFormat testF } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry file = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -133,13 +133,13 @@ public void Read_Archive_File_SymbolicLink(TarFormat format, TestTarFormat testF } [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_Folder_File(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_Folder_File(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "folder_file"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -153,7 +153,7 @@ public void Read_Archive_Folder_File(TarFormat format, TestTarFormat testFormat) } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry directory = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -174,13 +174,13 @@ public void Read_Archive_Folder_File(TarFormat format, TestTarFormat testFormat) } [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_Folder_File_Utf8(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_Folder_File_Utf8(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "folder_file_utf8"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -193,7 +193,7 @@ public void Read_Archive_Folder_File_Utf8(TarFormat format, TestTarFormat testFo } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry directory = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -214,13 +214,13 @@ public void Read_Archive_Folder_File_Utf8(TarFormat format, TestTarFormat testFo } [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_Folder_Subfolder_File(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_Folder_Subfolder_File(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "folder_subfolder_file"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -233,7 +233,7 @@ public void Read_Archive_Folder_Subfolder_File(TarFormat format, TestTarFormat t } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry parent = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -257,13 +257,13 @@ public void Read_Archive_Folder_Subfolder_File(TarFormat format, TestTarFormat t } [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_FolderSymbolicLink_Folder_Subfolder_File(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_FolderSymbolicLink_Folder_Subfolder_File(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "foldersymlink_folder_subfolder_file"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -276,7 +276,7 @@ public void Read_Archive_FolderSymbolicLink_Folder_Subfolder_File(TarFormat form } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry childlink = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -303,13 +303,13 @@ public void Read_Archive_FolderSymbolicLink_Folder_Subfolder_File(TarFormat form } [Theory] - [InlineData(TarFormat.V7, TestTarFormat.v7)] - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_Many_Small_Files(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.V7, TestTarFormat.v7)] + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_Many_Small_Files(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "many_small_files"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -322,7 +322,7 @@ public void Read_Archive_Many_Small_Files(TarFormat format, TestTarFormat testFo } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); List entries = new List(); TarEntry entry; @@ -348,7 +348,7 @@ public void Read_Archive_Many_Small_Files(TarFormat format, TestTarFormat testFo int directoriesCount = entries.Count(e => e.EntryType == TarEntryType.Directory); Assert.Equal(10, directoriesCount); - TarEntryType regularFileEntryType = format == TarFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; + TarEntryType regularFileEntryType = format == TarEntryFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; for (int i = 0; i < 10; i++) { int filesCount = entries.Count(e => e.EntryType == regularFileEntryType && e.Name.StartsWith($"{i}/")); @@ -358,12 +358,12 @@ public void Read_Archive_Many_Small_Files(TarFormat format, TestTarFormat testFo [Theory] // V7 does not support longer filenames - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_LongPath_Splitable_Under255(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_LongPath_Splitable_Under255(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "longpath_splitable_under255"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -376,7 +376,7 @@ public void Read_Archive_LongPath_Splitable_Under255(TarFormat format, TestTarFo } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry directory = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -398,12 +398,12 @@ public void Read_Archive_LongPath_Splitable_Under255(TarFormat format, TestTarFo [Theory] // V7 does not support block devices, character devices or fifos - [InlineData(TarFormat.Ustar, TestTarFormat.ustar)] - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_SpecialFiles(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.Ustar, TestTarFormat.ustar)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_SpecialFiles(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "specialfiles"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -416,7 +416,7 @@ public void Read_Archive_SpecialFiles(TarFormat format, TestTarFormat testFormat } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); PosixTarEntry blockDevice = reader.GetNextEntry() as PosixTarEntry; Assert.Equal(format, reader.Format); @@ -441,11 +441,11 @@ public void Read_Archive_SpecialFiles(TarFormat format, TestTarFormat testFormat [Theory] // Neither V7 not Ustar can handle links with long target filenames - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_File_LongSymbolicLink(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_File_LongSymbolicLink(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "file_longsymlink"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -458,7 +458,7 @@ public void Read_Archive_File_LongSymbolicLink(TarFormat format, TestTarFormat t } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry directory = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -483,11 +483,11 @@ public void Read_Archive_File_LongSymbolicLink(TarFormat format, TestTarFormat t [Theory] // Neither V7 not Ustar can handle a path that does not have separators that can be split under 100 bytes - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_LongFileName_Over100_Under255(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_LongFileName_Over100_Under255(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "longfilename_over100_under255"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -500,7 +500,7 @@ public void Read_Archive_LongFileName_Over100_Under255(TarFormat format, TestTar } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry file = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -519,11 +519,11 @@ public void Read_Archive_LongFileName_Over100_Under255(TarFormat format, TestTar [Theory] // Neither V7 not Ustar can handle path lenghts waaaay beyond name+prefix length - [InlineData(TarFormat.Pax, TestTarFormat.pax)] - [InlineData(TarFormat.Pax, TestTarFormat.pax_gea)] - [InlineData(TarFormat.Gnu, TestTarFormat.gnu)] - [InlineData(TarFormat.Gnu, TestTarFormat.oldgnu)] - public void Read_Archive_LongPath_Over255(TarFormat format, TestTarFormat testFormat) + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax)] + [InlineData(TarEntryFormat.Pax, TestTarFormat.pax_gea)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.gnu)] + [InlineData(TarEntryFormat.Gnu, TestTarFormat.oldgnu)] + public void Read_Archive_LongPath_Over255(TarEntryFormat format, TestTarFormat testFormat) { string testCaseName = "longpath_over255"; using MemoryStream ms = GetTarMemoryStream(CompressionMethod.Uncompressed, testFormat, testCaseName); @@ -536,7 +536,7 @@ public void Read_Archive_LongPath_Over255(TarFormat format, TestTarFormat testFo } // Format is determined after reading the first entry, not on the constructor - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry directory = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -556,7 +556,7 @@ public void Read_Archive_LongPath_Over255(TarFormat format, TestTarFormat testFo Assert.Null(reader.GetNextEntry()); } - private void Verify_Archive_RegularFile(TarEntry file, TarFormat format, IReadOnlyDictionary gea, string expectedFileName, string expectedContents) + private void Verify_Archive_RegularFile(TarEntry file, TarEntryFormat format, IReadOnlyDictionary gea, string expectedFileName, string expectedContents) { Assert.NotNull(file); @@ -572,7 +572,7 @@ private void Verify_Archive_RegularFile(TarEntry file, TarFormat format, IReadOn Assert.Equal(expectedContents, contents); } - TarEntryType expectedEntryType = format == TarFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; + TarEntryType expectedEntryType = format == TarEntryFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; Assert.Equal(expectedEntryType, file.EntryType); Assert.Equal(AssetGid, file.Gid); diff --git a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs index a9eccc625c0388..bad9bf8fa179bf 100644 --- a/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarReader/TarReader.GetNextEntry.Tests.cs @@ -48,7 +48,7 @@ public void LongEndMarkers_DoNotAdvanceStream() { using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry entry = new UstarTarEntry(TarEntryType.Directory, "dir"); writer.WriteEntry(entry); @@ -72,7 +72,7 @@ public void GetNextEntry_CopyDataTrue_SeekableArchive() { string expectedText = "Hello world!"; MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry entry1 = new UstarTarEntry(TarEntryType.RegularFile, "file.txt"); entry1.DataStream = new MemoryStream(); @@ -118,7 +118,7 @@ public void GetNextEntry_CopyDataTrue_UnseekableArchive() { string expectedText = "Hello world!"; MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry entry1 = new UstarTarEntry(TarEntryType.RegularFile, "file.txt"); entry1.DataStream = new MemoryStream(); @@ -165,7 +165,7 @@ public void GetNextEntry_CopyDataTrue_UnseekableArchive() public void GetNextEntry_CopyDataFalse_UnseekableArchive_Exceptions() { MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry entry1 = new UstarTarEntry(TarEntryType.RegularFile, "file.txt"); entry1.DataStream = new MemoryStream(); @@ -208,7 +208,7 @@ public void GetNextEntry_CopyDataFalse_UnseekableArchive_Exceptions() public void GetNextEntry_UnseekableArchive_ReplaceDataStream_ExcludeFromDisposing(bool copyData) { MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry entry1 = new UstarTarEntry(TarEntryType.RegularFile, "file.txt"); entry1.DataStream = new MemoryStream(); diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.Tests.cs index 855d52d9bcad31..aab1bb1395d0c8 100644 --- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.Tests.cs @@ -13,7 +13,7 @@ public class TarWriter_Tests : TarTestsBase public void Constructors_NullStream() { Assert.Throws(() => new TarWriter(archiveStream: null)); - Assert.Throws(() => new TarWriter(archiveStream: null, TarFormat.V7)); + Assert.Throws(() => new TarWriter(archiveStream: null, TarEntryFormat.V7)); } [Fact] @@ -36,29 +36,29 @@ public void Constructor_Format() using MemoryStream archiveStream = new MemoryStream(); using TarWriter writerDefault = new TarWriter(archiveStream, leaveOpen: true); - Assert.Equal(TarFormat.Pax, writerDefault.Format); + Assert.Equal(TarEntryFormat.Pax, writerDefault.Format); - using TarWriter writerV7 = new TarWriter(archiveStream, TarFormat.V7, leaveOpen: true); - Assert.Equal(TarFormat.V7, writerV7.Format); + using TarWriter writerV7 = new TarWriter(archiveStream, TarEntryFormat.V7, leaveOpen: true); + Assert.Equal(TarEntryFormat.V7, writerV7.Format); - using TarWriter writerUstar = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true); - Assert.Equal(TarFormat.Ustar, writerUstar.Format); + using TarWriter writerUstar = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true); + Assert.Equal(TarEntryFormat.Ustar, writerUstar.Format); - using TarWriter writerPax = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true); - Assert.Equal(TarFormat.Pax, writerPax.Format); + using TarWriter writerPax = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true); + Assert.Equal(TarEntryFormat.Pax, writerPax.Format); - using TarWriter writerGnu = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true); - Assert.Equal(TarFormat.Gnu, writerGnu.Format); + using TarWriter writerGnu = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true); + Assert.Equal(TarEntryFormat.Gnu, writerGnu.Format); using TarWriter writerNullGeaDefaultPax = new TarWriter(archiveStream, leaveOpen: true, globalExtendedAttributes: null); - Assert.Equal(TarFormat.Pax, writerNullGeaDefaultPax.Format); + Assert.Equal(TarEntryFormat.Pax, writerNullGeaDefaultPax.Format); using TarWriter writerValidGeaDefaultPax = new TarWriter(archiveStream, leaveOpen: true, globalExtendedAttributes: new Dictionary()); - Assert.Equal(TarFormat.Pax, writerValidGeaDefaultPax.Format); + Assert.Equal(TarEntryFormat.Pax, writerValidGeaDefaultPax.Format); - Assert.Throws(() => new TarWriter(archiveStream, TarFormat.Unknown)); - Assert.Throws(() => new TarWriter(archiveStream, (TarFormat)int.MinValue)); - Assert.Throws(() => new TarWriter(archiveStream, (TarFormat)int.MaxValue)); + Assert.Throws(() => new TarWriter(archiveStream, TarEntryFormat.Unknown)); + Assert.Throws(() => new TarWriter(archiveStream, (TarEntryFormat)int.MinValue)); + Assert.Throws(() => new TarWriter(archiveStream, (TarEntryFormat)int.MaxValue)); } [Fact] @@ -67,7 +67,7 @@ public void Constructors_UnwritableStream_Throws() using MemoryStream archiveStream = new MemoryStream(); using WrappedStream wrappedStream = new WrappedStream(archiveStream, canRead: true, canWrite: false, canSeek: false); Assert.Throws(() => new TarWriter(wrappedStream)); - Assert.Throws(() => new TarWriter(wrappedStream, TarFormat.V7)); + Assert.Throws(() => new TarWriter(wrappedStream, TarEntryFormat.V7)); } [Fact] @@ -96,7 +96,7 @@ public void Write_To_UnseekableStream() using (TarReader reader = new TarReader(wrapped)) { TarEntry entry = reader.GetNextEntry(); - Assert.Equal(TarFormat.Pax, reader.Format); + Assert.Equal(TarEntryFormat.Pax, reader.Format); Assert.Equal(TarEntryType.RegularFile, entry.EntryType); Assert.Null(reader.GetNextEntry()); } @@ -106,7 +106,7 @@ public void Write_To_UnseekableStream() public void VerifyChecksumV7() { using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, TarFormat.V7, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, TarEntryFormat.V7, leaveOpen: true)) { V7TarEntry entry = new V7TarEntry( // '\0' = 0 diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Gnu.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Gnu.Tests.cs index da5cc1117f1240..5e7dbdc3164bc0 100644 --- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Gnu.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Gnu.Tests.cs @@ -13,7 +13,7 @@ public class TarWriter_WriteEntry_Gnu_Tests : TarTestsBase public void Write_V7RegularFileEntry_As_RegularFileEntry() { using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, archiveFormat: TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, archiveFormat: TarEntryFormat.Gnu, leaveOpen: true)) { V7TarEntry entry = new V7TarEntry(TarEntryType.V7RegularFile, InitialEntryName); @@ -36,7 +36,7 @@ public void Write_V7RegularFileEntry_As_RegularFileEntry() public void WriteRegularFile() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry regularFile = new GnuTarEntry(TarEntryType.RegularFile, InitialEntryName); SetRegularFile(regularFile); @@ -56,7 +56,7 @@ public void WriteRegularFile() public void WriteHardLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry hardLink = new GnuTarEntry(TarEntryType.HardLink, InitialEntryName); SetHardLink(hardLink); @@ -76,7 +76,7 @@ public void WriteHardLink() public void WriteSymbolicLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry symbolicLink = new GnuTarEntry(TarEntryType.SymbolicLink, InitialEntryName); SetSymbolicLink(symbolicLink); @@ -96,7 +96,7 @@ public void WriteSymbolicLink() public void WriteDirectory() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry directory = new GnuTarEntry(TarEntryType.Directory, InitialEntryName); SetDirectory(directory); @@ -116,7 +116,7 @@ public void WriteDirectory() public void WriteCharacterDevice() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry charDevice = new GnuTarEntry(TarEntryType.CharacterDevice, InitialEntryName); SetCharacterDevice(charDevice); @@ -136,7 +136,7 @@ public void WriteCharacterDevice() public void WriteBlockDevice() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry blockDevice = new GnuTarEntry(TarEntryType.BlockDevice, InitialEntryName); SetBlockDevice(blockDevice); @@ -156,7 +156,7 @@ public void WriteBlockDevice() public void WriteFifo() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry fifo = new GnuTarEntry(TarEntryType.Fifo, InitialEntryName); SetFifo(fifo); @@ -183,7 +183,7 @@ public void Write_Long_Name(TarEntryType entryType) string longName = new string('a', 101); using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry entry = new GnuTarEntry(entryType, longName); writer.WriteEntry(entry); @@ -207,7 +207,7 @@ public void Write_LongLinKName(TarEntryType entryType) string longLinkName = new string('a', 101); using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry entry = new GnuTarEntry(entryType, "file.txt"); entry.LinkName = longLinkName; @@ -234,7 +234,7 @@ public void Write_LongName_And_LongLinKName(TarEntryType entryType) string longLinkName = new string('a', 101); using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Gnu, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Gnu, leaveOpen: true)) { GnuTarEntry entry = new GnuTarEntry(entryType, longName); entry.LinkName = longLinkName; diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Pax.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Pax.Tests.cs index a746c609d23db2..d04a40cab1c7cb 100644 --- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Pax.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Pax.Tests.cs @@ -15,7 +15,7 @@ public class TarWriter_WriteEntry_Pax_Tests : TarTestsBase public void Write_V7RegularFileEntry_As_RegularFileEntry() { using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, archiveFormat: TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, archiveFormat: TarEntryFormat.Pax, leaveOpen: true)) { V7TarEntry entry = new V7TarEntry(TarEntryType.V7RegularFile, InitialEntryName); @@ -38,7 +38,7 @@ public void Write_V7RegularFileEntry_As_RegularFileEntry() public void WriteRegularFile() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry regularFile = new PaxTarEntry(TarEntryType.RegularFile, InitialEntryName); SetRegularFile(regularFile); @@ -58,7 +58,7 @@ public void WriteRegularFile() public void WriteHardLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry hardLink = new PaxTarEntry(TarEntryType.HardLink, InitialEntryName); SetHardLink(hardLink); @@ -78,7 +78,7 @@ public void WriteHardLink() public void WriteSymbolicLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry symbolicLink = new PaxTarEntry(TarEntryType.SymbolicLink, InitialEntryName); SetSymbolicLink(symbolicLink); @@ -98,7 +98,7 @@ public void WriteSymbolicLink() public void WriteDirectory() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry directory = new PaxTarEntry(TarEntryType.Directory, InitialEntryName); SetDirectory(directory); @@ -118,7 +118,7 @@ public void WriteDirectory() public void WriteCharacterDevice() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry charDevice = new PaxTarEntry(TarEntryType.CharacterDevice, InitialEntryName); SetCharacterDevice(charDevice); @@ -138,7 +138,7 @@ public void WriteCharacterDevice() public void WriteBlockDevice() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry blockDevice = new PaxTarEntry(TarEntryType.BlockDevice, InitialEntryName); SetBlockDevice(blockDevice); @@ -158,7 +158,7 @@ public void WriteBlockDevice() public void WriteFifo() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry fifo = new PaxTarEntry(TarEntryType.Fifo, InitialEntryName); SetFifo(fifo); @@ -184,7 +184,7 @@ public void WritePaxAttributes_CustomAttribute() extendedAttributes.Add(expectedKey, expectedValue); using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry regularFile = new PaxTarEntry(TarEntryType.RegularFile, InitialEntryName, extendedAttributes); SetRegularFile(regularFile); @@ -221,7 +221,7 @@ public void WritePaxAttributes_Timestamps() extendedAttributes.Add("ctime", ConvertDateTimeOffsetToDouble(TestChangeTime).ToString("F6", CultureInfo.InvariantCulture)); using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry regularFile = new PaxTarEntry(TarEntryType.RegularFile, InitialEntryName, extendedAttributes); SetRegularFile(regularFile); @@ -252,7 +252,7 @@ public void WritePaxAttributes_LongGroupName_LongUserName() string groupName = "IAmAGroupNameWhoseLengthIsWayBeyondTheThirtyTwoByteLimit"; using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Pax, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Pax, leaveOpen: true)) { PaxTarEntry regularFile = new PaxTarEntry(TarEntryType.RegularFile, InitialEntryName); SetRegularFile(regularFile); diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Ustar.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Ustar.Tests.cs index a130ae87edc3cd..39613ca123a060 100644 --- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Ustar.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Ustar.Tests.cs @@ -13,7 +13,7 @@ public class TarWriter_WriteEntry_Ustar_Tests : TarTestsBase public void Write_V7RegularFileEntry_As_RegularFileEntry() { using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, archiveFormat: TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, archiveFormat: TarEntryFormat.Ustar, leaveOpen: true)) { V7TarEntry entry = new V7TarEntry(TarEntryType.V7RegularFile, InitialEntryName); @@ -36,7 +36,7 @@ public void Write_V7RegularFileEntry_As_RegularFileEntry() public void WriteRegularFile() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry regularFile = new UstarTarEntry(TarEntryType.RegularFile, InitialEntryName); SetRegularFile(regularFile); @@ -56,7 +56,7 @@ public void WriteRegularFile() public void WriteHardLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry hardLink = new UstarTarEntry(TarEntryType.HardLink, InitialEntryName); SetHardLink(hardLink); @@ -76,7 +76,7 @@ public void WriteHardLink() public void WriteSymbolicLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry symbolicLink = new UstarTarEntry(TarEntryType.SymbolicLink, InitialEntryName); SetSymbolicLink(symbolicLink); @@ -96,7 +96,7 @@ public void WriteSymbolicLink() public void WriteDirectory() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry directory = new UstarTarEntry(TarEntryType.Directory, InitialEntryName); SetDirectory(directory); @@ -116,7 +116,7 @@ public void WriteDirectory() public void WriteCharacterDevice() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry charDevice = new UstarTarEntry(TarEntryType.CharacterDevice, InitialEntryName); SetCharacterDevice(charDevice); @@ -136,7 +136,7 @@ public void WriteCharacterDevice() public void WriteBlockDevice() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry blockDevice = new UstarTarEntry(TarEntryType.BlockDevice, InitialEntryName); SetBlockDevice(blockDevice); @@ -156,7 +156,7 @@ public void WriteBlockDevice() public void WriteFifo() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.Ustar, leaveOpen: true)) { UstarTarEntry fifo = new UstarTarEntry(TarEntryType.Fifo, InitialEntryName); SetFifo(fifo); diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.V7.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.V7.Tests.cs index 7b74d769fa13ed..1b0a325d089318 100644 --- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.V7.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.V7.Tests.cs @@ -14,7 +14,7 @@ public void ThrowIf_WriteEntry_UnsupportedFile() { // Verify that entry types that can be manually constructed in other types, cannot be inserted in a v7 writer using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, archiveFormat: TarFormat.V7, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, archiveFormat: TarEntryFormat.V7, leaveOpen: true)) { // Entry types supported in ustar but not in v7 Assert.Throws(() => writer.WriteEntry(new UstarTarEntry(TarEntryType.BlockDevice, InitialEntryName))); @@ -36,19 +36,19 @@ public void ThrowIf_WriteEntry_UnsupportedFile() } [Theory] - [InlineData(TarFormat.Ustar)] - [InlineData(TarFormat.Pax)] - [InlineData(TarFormat.Gnu)] - public void Write_RegularFileEntry_As_V7RegularFileEntry(TarFormat entryFormat) + [InlineData(TarEntryFormat.Ustar)] + [InlineData(TarEntryFormat.Pax)] + [InlineData(TarEntryFormat.Gnu)] + public void Write_RegularFileEntry_As_V7RegularFileEntry(TarEntryFormat entryFormat) { using MemoryStream archive = new MemoryStream(); - using (TarWriter writer = new TarWriter(archive, archiveFormat: TarFormat.V7, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archive, archiveFormat: TarEntryFormat.V7, leaveOpen: true)) { TarEntry entry = entryFormat switch { - TarFormat.Ustar => new UstarTarEntry(TarEntryType.RegularFile, InitialEntryName), - TarFormat.Pax => new PaxTarEntry(TarEntryType.RegularFile, InitialEntryName), - TarFormat.Gnu => new GnuTarEntry(TarEntryType.RegularFile, InitialEntryName), + TarEntryFormat.Ustar => new UstarTarEntry(TarEntryType.RegularFile, InitialEntryName), + TarEntryFormat.Pax => new PaxTarEntry(TarEntryType.RegularFile, InitialEntryName), + TarEntryFormat.Gnu => new GnuTarEntry(TarEntryType.RegularFile, InitialEntryName), _ => throw new FormatException() }; @@ -72,7 +72,7 @@ public void Write_RegularFileEntry_As_V7RegularFileEntry(TarFormat entryFormat) public void WriteRegularFile() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.V7, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.V7, leaveOpen: true)) { V7TarEntry oldRegularFile = new V7TarEntry(TarEntryType.V7RegularFile, InitialEntryName); SetRegularFile(oldRegularFile); @@ -92,7 +92,7 @@ public void WriteRegularFile() public void WriteHardLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.V7, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.V7, leaveOpen: true)) { V7TarEntry hardLink = new V7TarEntry(TarEntryType.HardLink, InitialEntryName); SetHardLink(hardLink); @@ -112,7 +112,7 @@ public void WriteHardLink() public void WriteSymbolicLink() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.V7, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.V7, leaveOpen: true)) { V7TarEntry symbolicLink = new V7TarEntry(TarEntryType.SymbolicLink, InitialEntryName); SetSymbolicLink(symbolicLink); @@ -132,7 +132,7 @@ public void WriteSymbolicLink() public void WriteDirectory() { using MemoryStream archiveStream = new MemoryStream(); - using (TarWriter writer = new TarWriter(archiveStream, TarFormat.V7, leaveOpen: true)) + using (TarWriter writer = new TarWriter(archiveStream, TarEntryFormat.V7, leaveOpen: true)) { V7TarEntry directory = new V7TarEntry(TarEntryType.Directory, InitialEntryName); SetDirectory(directory); 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 95239178941661..095aa19c219a20 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 @@ -12,14 +12,14 @@ public partial class TarWriter_WriteEntry_File_Tests : TarTestsBase private static bool IsRemoteExecutorSupportedAndOnUnixAndSuperUser => RemoteExecutor.IsSupported && PlatformDetection.IsUnixAndSuperUser; [ConditionalTheory(nameof(IsRemoteExecutorSupportedAndOnUnixAndSuperUser))] - [InlineData(TarFormat.Ustar)] - [InlineData(TarFormat.Pax)] - [InlineData(TarFormat.Gnu)] - public void Add_Fifo(TarFormat format) + [InlineData(TarEntryFormat.Ustar)] + [InlineData(TarEntryFormat.Pax)] + [InlineData(TarEntryFormat.Gnu)] + public void Add_Fifo(TarEntryFormat format) { RemoteExecutor.Invoke((string strFormat) => { - TarFormat expectedFormat = Enum.Parse(strFormat); + TarEntryFormat expectedFormat = Enum.Parse(strFormat); using TempDirectory root = new TempDirectory(); string fifoName = "fifofile"; @@ -36,7 +36,7 @@ public void Add_Fifo(TarFormat format) archive.Seek(0, SeekOrigin.Begin); using (TarReader reader = new TarReader(archive)) { - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); PosixTarEntry entry = reader.GetNextEntry() as PosixTarEntry; Assert.Equal(expectedFormat, reader.Format); @@ -55,14 +55,14 @@ public void Add_Fifo(TarFormat format) } [ConditionalTheory(nameof(IsRemoteExecutorSupportedAndOnUnixAndSuperUser))] - [InlineData(TarFormat.Ustar)] - [InlineData(TarFormat.Pax)] - [InlineData(TarFormat.Gnu)] - public void Add_BlockDevice(TarFormat format) + [InlineData(TarEntryFormat.Ustar)] + [InlineData(TarEntryFormat.Pax)] + [InlineData(TarEntryFormat.Gnu)] + public void Add_BlockDevice(TarEntryFormat format) { RemoteExecutor.Invoke((string strFormat) => { - TarFormat expectedFormat = Enum.Parse(strFormat); + TarEntryFormat expectedFormat = Enum.Parse(strFormat); using TempDirectory root = new TempDirectory(); string blockDevicePath = Path.Join(root.Path, AssetBlockDeviceFileName); @@ -79,7 +79,7 @@ public void Add_BlockDevice(TarFormat format) archive.Seek(0, SeekOrigin.Begin); using (TarReader reader = new TarReader(archive)) { - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); PosixTarEntry entry = reader.GetNextEntry() as PosixTarEntry; Assert.Equal(expectedFormat, reader.Format); @@ -101,14 +101,14 @@ public void Add_BlockDevice(TarFormat format) } [ConditionalTheory(nameof(IsRemoteExecutorSupportedAndOnUnixAndSuperUser))] - [InlineData(TarFormat.Ustar)] - [InlineData(TarFormat.Pax)] - [InlineData(TarFormat.Gnu)] - public void Add_CharacterDevice(TarFormat format) + [InlineData(TarEntryFormat.Ustar)] + [InlineData(TarEntryFormat.Pax)] + [InlineData(TarEntryFormat.Gnu)] + public void Add_CharacterDevice(TarEntryFormat format) { RemoteExecutor.Invoke((string strFormat) => { - TarFormat expectedFormat = Enum.Parse(strFormat); + TarEntryFormat expectedFormat = Enum.Parse(strFormat); using TempDirectory root = new TempDirectory(); string characterDevicePath = Path.Join(root.Path, AssetCharacterDeviceFileName); @@ -124,7 +124,7 @@ public void Add_CharacterDevice(TarFormat format) archive.Seek(0, SeekOrigin.Begin); using (TarReader reader = new TarReader(archive)) { - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); PosixTarEntry entry = reader.GetNextEntry() as PosixTarEntry; Assert.Equal(expectedFormat, reader.Format); diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs index 52d34232c4da7e..31781e75b9fcd5 100644 --- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs @@ -67,11 +67,11 @@ public void EntryName_NullOrEmpty() [ActiveIssue("https://github.com/dotnet/runtime/issues/69474", TestPlatforms.Linux)] [Theory] - [InlineData(TarFormat.V7)] - [InlineData(TarFormat.Ustar)] - [InlineData(TarFormat.Pax)] - [InlineData(TarFormat.Gnu)] - public void Add_File(TarFormat format) + [InlineData(TarEntryFormat.V7)] + [InlineData(TarEntryFormat.Ustar)] + [InlineData(TarEntryFormat.Pax)] + [InlineData(TarEntryFormat.Gnu)] + public void Add_File(TarEntryFormat format) { using TempDirectory root = new TempDirectory(); string fileName = "file.txt"; @@ -92,12 +92,12 @@ public void Add_File(TarFormat format) archive.Seek(0, SeekOrigin.Begin); using (TarReader reader = new TarReader(archive)) { - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry entry = reader.GetNextEntry(); Assert.NotNull(entry); Assert.Equal(format, reader.Format); Assert.Equal(fileName, entry.Name); - TarEntryType expectedEntryType = format is TarFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; + TarEntryType expectedEntryType = format is TarEntryFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile; Assert.Equal(expectedEntryType, entry.EntryType); Assert.True(entry.Length > 0); Assert.NotNull(entry.DataStream); @@ -115,15 +115,15 @@ public void Add_File(TarFormat format) } [Theory] - [InlineData(TarFormat.V7, false)] - [InlineData(TarFormat.V7, true)] - [InlineData(TarFormat.Ustar, false)] - [InlineData(TarFormat.Ustar, true)] - [InlineData(TarFormat.Pax, false)] - [InlineData(TarFormat.Pax, true)] - [InlineData(TarFormat.Gnu, false)] - [InlineData(TarFormat.Gnu, true)] - public void Add_Directory(TarFormat format, bool withContents) + [InlineData(TarEntryFormat.V7, false)] + [InlineData(TarEntryFormat.V7, true)] + [InlineData(TarEntryFormat.Ustar, false)] + [InlineData(TarEntryFormat.Ustar, true)] + [InlineData(TarEntryFormat.Pax, false)] + [InlineData(TarEntryFormat.Pax, true)] + [InlineData(TarEntryFormat.Gnu, false)] + [InlineData(TarEntryFormat.Gnu, true)] + public void Add_Directory(TarEntryFormat format, bool withContents) { using TempDirectory root = new TempDirectory(); string dirName = "dir"; @@ -146,7 +146,7 @@ public void Add_Directory(TarFormat format, bool withContents) archive.Seek(0, SeekOrigin.Begin); using (TarReader reader = new TarReader(archive)) { - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry entry = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -162,15 +162,15 @@ public void Add_Directory(TarFormat format, bool withContents) } [ConditionalTheory(typeof(MountHelper), nameof(MountHelper.CanCreateSymbolicLinks))] - [InlineData(TarFormat.V7, false)] - [InlineData(TarFormat.V7, true)] - [InlineData(TarFormat.Ustar, false)] - [InlineData(TarFormat.Ustar, true)] - [InlineData(TarFormat.Pax, false)] - [InlineData(TarFormat.Pax, true)] - [InlineData(TarFormat.Gnu, false)] - [InlineData(TarFormat.Gnu, true)] - public void Add_SymbolicLink(TarFormat format, bool createTarget) + [InlineData(TarEntryFormat.V7, false)] + [InlineData(TarEntryFormat.V7, true)] + [InlineData(TarEntryFormat.Ustar, false)] + [InlineData(TarEntryFormat.Ustar, true)] + [InlineData(TarEntryFormat.Pax, false)] + [InlineData(TarEntryFormat.Pax, true)] + [InlineData(TarEntryFormat.Gnu, false)] + [InlineData(TarEntryFormat.Gnu, true)] + public void Add_SymbolicLink(TarEntryFormat format, bool createTarget) { using TempDirectory root = new TempDirectory(); string targetName = "file.txt"; @@ -195,7 +195,7 @@ public void Add_SymbolicLink(TarFormat format, bool createTarget) archive.Seek(0, SeekOrigin.Begin); using (TarReader reader = new TarReader(archive)) { - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); TarEntry entry = reader.GetNextEntry(); Assert.Equal(format, reader.Format); @@ -233,12 +233,12 @@ public void Add_PaxGlobalExtendedAttributes_NoEntries(bool withAttributes) using (TarReader reader = new TarReader(archive)) { // Unknown until reading first entry - Assert.Equal(TarFormat.Unknown, reader.Format); + Assert.Equal(TarEntryFormat.Unknown, reader.Format); Assert.Null(reader.GlobalExtendedAttributes); Assert.Null(reader.GetNextEntry()); - Assert.Equal(TarFormat.Pax, reader.Format); + Assert.Equal(TarEntryFormat.Pax, reader.Format); Assert.NotNull(reader.GlobalExtendedAttributes); int expectedCount = withAttributes ? 1 : 0; diff --git a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Tests.cs b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Tests.cs index c68690c0a7fa4e..2722095996aa4c 100644 --- a/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Tests.cs +++ b/src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Tests.cs @@ -35,7 +35,7 @@ public void WriteEntry_FromUnseekableStream_AdvanceDataStream_WriteFromThatPosit Assert.NotNull(entry.DataStream); entry.DataStream.ReadByte(); // Advance one byte, now the expected string would be "ello file" - using (TarWriter writer = new TarWriter(destination, TarFormat.Ustar, leaveOpen: true)) + using (TarWriter writer = new TarWriter(destination, TarEntryFormat.Ustar, leaveOpen: true)) { writer.WriteEntry(entry); }