示例#1
0
        // Shared checksum and data length calculations for PAX entry writing.
        private void WriteAsPaxSharedInternal(Span <byte> buffer, out long actualLength)
        {
            actualLength = GetTotalDataBytesToWrite();

            int tmpChecksum = WritePosixName(buffer);

            tmpChecksum += WriteCommonFields(buffer, actualLength, TarHelpers.GetCorrectTypeFlagForFormat(TarEntryFormat.Pax, _typeFlag));
            tmpChecksum += WritePosixMagicAndVersion(buffer);
            tmpChecksum += WritePosixAndGnuSharedFields(buffer);

            _checksum = WriteChecksum(tmpChecksum, buffer);
        }
示例#2
0
        // Writes the V7 header fields to the specified buffer, calculates and writes the checksum, then returns the final data length.
        private long WriteV7FieldsToBuffer(Span <byte> buffer)
        {
            long         actualLength    = GetTotalDataBytesToWrite();
            TarEntryType actualEntryType = TarHelpers.GetCorrectTypeFlagForFormat(TarEntryFormat.V7, _typeFlag);

            int tmpChecksum = WriteName(buffer, out _);

            tmpChecksum += WriteCommonFields(buffer, actualLength, actualEntryType);
            _checksum    = WriteChecksum(tmpChecksum, buffer);

            return(actualLength);
        }
示例#3
0
        // Writes the Ustar header fields to the specified buffer, calculates and writes the checksum, then returns the final data length.
        private long WriteUstarFieldsToBuffer(Span <byte> buffer)
        {
            long         actualLength    = GetTotalDataBytesToWrite();
            TarEntryType actualEntryType = TarHelpers.GetCorrectTypeFlagForFormat(TarEntryFormat.Ustar, _typeFlag);

            int tmpChecksum = WritePosixName(buffer);

            tmpChecksum += WriteCommonFields(buffer, actualLength, actualEntryType);
            tmpChecksum += WritePosixMagicAndVersion(buffer);
            tmpChecksum += WritePosixAndGnuSharedFields(buffer);
            _checksum    = WriteChecksum(tmpChecksum, buffer);

            return(actualLength);
        }
示例#4
0
        // 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);
        }