예제 #1
0
        /// <summary>
        ///     Writes padding to the output stream to align it to the next 512-block.
        /// </summary>
        /// <param name="writtenSize">Number of written bytes since last alignment.</param>
        private void WritePadding(long writtenSize)
        {
            var padding = writtenSize < 0 ? TarBlock.Size : TarBlock.RemainingBlockSize(writtenSize);

            Array.Clear(_buffer, 0, Math.Min(_buffer.Length, padding));
            while (padding > 0)
            {
                var writeCount = Math.Min(_buffer.Length, padding);
                _stream.Write(_buffer, 0, writeCount);
                padding -= writeCount;
            }
        }
예제 #2
0
        /// <summary>
        ///     Moves the <see cref="_stream" /> to the end of the specified <paramref name="entryStream" />.
        /// </summary>
        /// <param name="entryStream">The entry stream.</param>
        private void MoveToEndOfStream(TarEntryStream entryStream)
        {
            // If previous stream isset, move past it's contents.
            if (entryStream == null)
            {
                return;
            }

            var length    = entryStream.Header.Size ?? 0;
            var padding   = TarBlock.RemainingBlockSize(length);
            var remaining = length - entryStream.PositionInternal + padding;

            // Skip remainder and re-align to 512 blocks
            for (; remaining > 0; remaining--)
            {
                _stream.ReadByte();
            }
        }