Propagate errors through NxFileStream

This commit is contained in:
Alex Barney 2024-05-13 20:15:23 -07:00
parent 9eb35528ac
commit 71fafcac85

View file

@ -25,7 +25,7 @@ public class NxFileStream : Stream
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
{ {
BaseFile.Read(out long bytesRead, Position, buffer.AsSpan(offset, count)); BaseFile.Read(out long bytesRead, Position, buffer.AsSpan(offset, count)).ThrowIfFailure();
Position += bytesRead; Position += bytesRead;
return (int)bytesRead; return (int)bytesRead;
@ -33,14 +33,14 @@ public class NxFileStream : Stream
public override void Write(byte[] buffer, int offset, int count) public override void Write(byte[] buffer, int offset, int count)
{ {
BaseFile.Write(Position, buffer.AsSpan(offset, count)); BaseFile.Write(Position, buffer.AsSpan(offset, count)).ThrowIfFailure();
Position += count; Position += count;
} }
public override void Flush() public override void Flush()
{ {
BaseFile.Flush(); BaseFile.Flush().ThrowIfFailure();
} }
public override long Seek(long offset, SeekOrigin origin) public override long Seek(long offset, SeekOrigin origin)