// Writes the current header as a PAX entry into the archive stream. // Makes sure to add the preceding exteded attributes entry before the actual entry. internal void WriteAsPax(Stream archiveStream, Span <byte> buffer) { // First, we write the preceding extended attributes header TarHeader extendedAttributesHeader = default; // Fill the current header's dict CollectExtendedAttributesFromStandardFieldsIfNeeded(); // And pass them to the extended attributes header for writing extendedAttributesHeader.WriteAsPaxExtendedAttributes(archiveStream, buffer, _extendedAttributes, isGea: false); buffer.Clear(); // Reset it to reuse it // Second, we write this header as a normal one WriteAsPaxInternal(archiveStream, buffer); }
// Creates a PAX Global Extended Attributes header and writes it into the specified archive stream. internal static void WriteGlobalExtendedAttributesHeader(Stream archiveStream, Span <byte> buffer, IEnumerable <KeyValuePair <string, string> > globalExtendedAttributes) { TarHeader geaHeader = default; geaHeader._name = GenerateGlobalExtendedAttributeName(); geaHeader._mode = (int)TarHelpers.DefaultMode; geaHeader._typeFlag = TarEntryType.GlobalExtendedAttributes; geaHeader._linkName = string.Empty; geaHeader._magic = string.Empty; geaHeader._version = string.Empty; geaHeader._gName = string.Empty; geaHeader._uName = string.Empty; geaHeader.WriteAsPaxExtendedAttributes(archiveStream, buffer, globalExtendedAttributes, isGea: true); }