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

@@ -89,7 +89,7 @@ public class Nintendo64 : IByteAddressableImage
stream.Position = 0;
var magicBytes = new byte[4];
stream.Read(magicBytes, 0, 4);
stream.EnsureRead(magicBytes, 0, 4);
var magic = BitConverter.ToUInt32(magicBytes, 0);
switch(magic)
@@ -120,7 +120,7 @@ public class Nintendo64 : IByteAddressableImage
stream.Position = 0;
var magicBytes = new byte[4];
stream.Read(magicBytes, 0, 4);
stream.EnsureRead(magicBytes, 0, 4);
var magic = BitConverter.ToUInt32(magicBytes, 0);
switch(magic)
@@ -154,7 +154,7 @@ public class Nintendo64 : IByteAddressableImage
_data = new byte[imageFilter.DataForkLength];
stream.Position = 0;
stream.Read(_data, 0, (int)imageFilter.DataForkLength);
stream.EnsureRead(_data, 0, (int)imageFilter.DataForkLength);
_imageInfo = new ImageInfo
{