Use Stream extension to ensure read operations return the requested number of bytes (unless EOF arrives first).

This commit is contained in:
2022-11-14 09:43:16 +00:00
parent f90cc6593f
commit 0eb589d785
178 changed files with 862 additions and 780 deletions

View File

@@ -49,7 +49,7 @@ public sealed partial class Anex86
return false;
var hdrB = new byte[Marshal.SizeOf<Header>()];
stream.Read(hdrB, 0, hdrB.Length);
stream.EnsureRead(hdrB, 0, hdrB.Length);
_header = Marshal.SpanToStructureLittleEndian<Header>(hdrB);

View File

@@ -51,7 +51,7 @@ public sealed partial class Anex86
return ErrorNumber.InvalidArgument;
var hdrB = new byte[Marshal.SizeOf<Header>()];
stream.Read(hdrB, 0, hdrB.Length);
stream.EnsureRead(hdrB, 0, hdrB.Length);
_header = Marshal.SpanToStructureLittleEndian<Header>(hdrB);
@@ -100,7 +100,7 @@ public sealed partial class Anex86
stream.Seek((long)((ulong)_header.hdrSize + sectorAddress * _imageInfo.SectorSize), SeekOrigin.Begin);
stream.Read(buffer, 0, (int)(length * _imageInfo.SectorSize));
stream.EnsureRead(buffer, 0, (int)(length * _imageInfo.SectorSize));
return ErrorNumber.NoError;
}