TagTool.Cache.TagCache.ResizeBlock C# (CSharp) Method

ResizeBlock() private method

Resizes a block of data in the file.
Cannot resize a block to a negative size
private ResizeBlock ( Stream stream, TagInstance tag, long startOffset, long oldSize, long newSize ) : void
stream Stream The stream.
tag TagTool.TagGroups.TagInstance The tag that the block belongs to, if any.
startOffset long The offset where the block to resize begins at.
oldSize long The current size of the block to resize.
newSize long The new size of the block.
return void
        private void ResizeBlock(Stream stream, TagInstance tag, long startOffset, long oldSize, long newSize)
        {
            if (newSize < 0)
                throw new ArgumentException("Cannot resize a block to a negative size");
            if (oldSize == newSize)
                return;
            var oldEndOffset = startOffset + oldSize;
            var sizeDelta = newSize - oldSize;
            StreamUtil.Copy(stream, oldEndOffset, oldEndOffset + sizeDelta, stream.Length - oldEndOffset);
            FixTagOffsets(oldEndOffset, sizeDelta, tag);
        }