Example #1
0
        /// <summary>
        ///     Resizes the last segment in the group, changing the total size of the group to be at least a specified size.
        /// </summary>
        /// <param name="newSize">The total amount of space that the resized group should at least occupy.</param>
        /// <param name="stream">The stream to write changes to.</param>
        public void Resize(int newSize, IStream stream)
        {
            if (Segments.Count == 0)
            {
                return;
            }

            FileSegment lastSegment        = Segments[Segments.Count - 1];
            int         newLastSegmentSize = newSize - (lastSegment.Offset - Offset);

            if (newLastSegmentSize <= 0)
            {
                throw new ArgumentException("Cannot shrink the group enough without deleting the last segment");
            }

            lastSegment.Resize(newLastSegmentSize, stream);
        }