// Constructor called when the user creates a TarEntry instance from scratch. internal TarEntry(TarEntryType entryType, string entryName, TarEntryFormat format, bool isGea) { ArgumentException.ThrowIfNullOrEmpty(entryName); Debug.Assert(!isGea || entryType is TarEntryType.GlobalExtendedAttributes); if (!isGea) { TarHelpers.ThrowIfEntryTypeNotSupported(entryType, format); } // Default values for fields shared by all supported formats _header = new TarHeader(format, entryName, TarHelpers.GetDefaultMode(entryType), DateTimeOffset.UtcNow, entryType); }
// Constructor called when converting an entry to the selected format. internal TarEntry(TarEntry other, TarEntryFormat format) { if (other is PaxGlobalExtendedAttributesTarEntry) { throw new InvalidOperationException(SR.TarCannotConvertPaxGlobalExtendedAttributesEntry); } TarEntryType compatibleEntryType = TarHelpers.GetCorrectTypeFlagForFormat(format, other.EntryType); TarHelpers.ThrowIfEntryTypeNotSupported(compatibleEntryType, format); _readerOfOrigin = other._readerOfOrigin; _header = new TarHeader(format, compatibleEntryType, other._header); }
// Constructor called when the user creates a TarEntry instance from scratch. internal TarEntry(TarEntryType entryType, string entryName, TarEntryFormat format, bool isGea) { ArgumentException.ThrowIfNullOrEmpty(entryName); Debug.Assert(!isGea || entryType is TarEntryType.GlobalExtendedAttributes); if (!isGea) { TarHelpers.ThrowIfEntryTypeNotSupported(entryType, format); } _header = default; _header._format = format; // Default values for fields shared by all supported formats _header._name = entryName; _header._mode = (int)TarHelpers.DefaultMode; _header._mTime = DateTimeOffset.UtcNow; _header._typeFlag = entryType; _header._linkName = string.Empty; }