mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use Stream extension to ensure read operations return the requested number of bytes (unless EOF arrives first).
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user