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

@@ -35,12 +35,13 @@ namespace Aaru.Devices.Linux;
using System;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interop;
using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.Decoders.SecureDigital;
using Aaru.Helpers;
using Marshal = System.Runtime.InteropServices.Marshal;
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
using VendorString = Aaru.Decoders.MMC.VendorString;
@@ -219,7 +220,7 @@ partial class Device : Devices.Device
var usbFs = new FileStream(resolvedLink + "/descriptors", FileMode.Open, FileAccess.Read);
var usbBuf = new byte[65536];
int usbCount = usbFs.Read(usbBuf, 0, 65536);
int usbCount = usbFs.EnsureRead(usbBuf, 0, 65536);
dev.UsbDescriptors = new byte[usbCount];
Array.Copy(usbBuf, 0, dev.UsbDescriptors, 0, usbCount);
usbFs.Close();
@@ -377,7 +378,7 @@ partial class Device : Devices.Device
var cisFs = new FileStream(possibleDir + "/cis", FileMode.Open, FileAccess.Read);
var cisBuf = new byte[65536];
int cisCount = cisFs.Read(cisBuf, 0, 65536);
int cisCount = cisFs.EnsureRead(cisBuf, 0, 65536);
dev.Cis = new byte[cisCount];
Array.Copy(cisBuf, 0, dev.Cis, 0, cisCount);
cisFs.Close();