Skip to content

Commit

Permalink
Fix StreamView Position property
Browse files Browse the repository at this point in the history
Setting the position past the length is expected to increase the length
of the stream.
  • Loading branch information
jeremy-visionaid committed Oct 8, 2024
1 parent 578d5a6 commit 82d09cf
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions sources/OpenMcdf/StreamView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,8 @@ public override void Flush()

public override long Position
{
get
{
return position;
}

set
{
if (position > length - 1)
throw new ArgumentOutOfRangeException(nameof(value));

position = value;
}
get => position;
set => Seek(value, SeekOrigin.Begin);
}

public override int Read(byte[] buffer, int offset, int count)
Expand Down Expand Up @@ -184,7 +174,7 @@ public override long Seek(long offset, SeekOrigin origin)
break;
}

if (length <= position) // Don't adjust the length when position is inside the bounds of 0 and the current length.
if (position > length)
AdjustLength(position);

return position;
Expand Down

0 comments on commit 82d09cf

Please sign in to comment.