Implemented reading SD/MMC using buffered OS calls.

This commit is contained in:
2020-12-12 22:48:03 +00:00
parent 04a2626125
commit c788a4ded5
12 changed files with 114 additions and 3 deletions

View File

@@ -594,5 +594,30 @@ namespace Aaru.Devices.Linux
return Encoding.ASCII.GetString(resultString);
}
internal static int BufferedOsRead(int fd, out byte[] buffer, long offset, uint length, out double duration)
{
buffer = new byte[length];
DateTime start = DateTime.Now;
long sense = Extern.lseek(fd, offset, SeekWhence.Begin);
DateTime end = DateTime.Now;
if(sense < 0)
{
duration = (end - start).TotalMilliseconds;
return Marshal.GetLastWin32Error();
}
sense = DetectOS.Is64Bit ? Extern.read64(fd, buffer, length) : Extern.read(fd, buffer, (int)length);
end = DateTime.Now;
duration = (end - start).TotalMilliseconds;
return sense < 0 ? Marshal.GetLastWin32Error() : 0;
}
}
}