Browse Source

Fix Typo and Offset

* While checking ChunkedMemoryStream i saw differences in the Seek method.
pull/2935/head
Stefan Nikolei 1 year ago
parent
commit
0b8cfb19d9
  1. 21
      src/ImageSharp/IO/BufferedReadStream.cs

21
src/ImageSharp/IO/BufferedReadStream.cs

@ -69,7 +69,7 @@ internal sealed class BufferedReadStream : Stream
} }
/// <summary> /// <summary>
/// Gets the number indicating the EOF hits occured while reading from this instance. /// Gets the number indicating the EOF hits occurred while reading from this instance.
/// </summary> /// </summary>
public int EofHitCount { get; private set; } public int EofHitCount { get; private set; }
@ -213,20 +213,13 @@ internal sealed class BufferedReadStream : Stream
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Seek(long offset, SeekOrigin origin) public override long Seek(long offset, SeekOrigin origin)
{ {
switch (origin) this.Position = origin switch
{ {
case SeekOrigin.Begin: SeekOrigin.Begin => (int)offset,
this.Position = offset; SeekOrigin.Current => (int)(this.Position + offset),
break; SeekOrigin.End => (int)(this.Length + offset),
_ => throw new ArgumentOutOfRangeException(nameof(offset)),
case SeekOrigin.Current: };
this.Position += offset;
break;
case SeekOrigin.End:
this.Position = this.Length - offset;
break;
}
return this.readerPosition; return this.readerPosition;
} }

Loading…
Cancel
Save