mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Convert part of loop into LINQ.
This commit is contained in:
Submodule Aaru.Decryption updated: 73b212d3bb...a84d4c28f6
@@ -1647,32 +1647,27 @@ namespace Aaru.Devices.Remote
|
|||||||
|
|
||||||
int off = tmp.Length;
|
int off = tmp.Length;
|
||||||
|
|
||||||
foreach(Device.MmcSingleCommand command in commands)
|
foreach(AaruCmdSdhci cmd in commands.Select(command => new AaruCmdSdhci
|
||||||
|
{
|
||||||
|
application = command.isApplication,
|
||||||
|
argument = command.argument,
|
||||||
|
block_size = command.blockSize,
|
||||||
|
blocks = command.blocks,
|
||||||
|
buf_len = (uint)(command.buffer?.Length ?? 0),
|
||||||
|
command = command.command,
|
||||||
|
flags = command.flags,
|
||||||
|
timeout = timeout,
|
||||||
|
write = command.write
|
||||||
|
}))
|
||||||
{
|
{
|
||||||
var cmd = new AaruCmdSdhci
|
|
||||||
{
|
|
||||||
application = command.isApplication,
|
|
||||||
argument = command.argument,
|
|
||||||
block_size = command.blockSize,
|
|
||||||
blocks = command.blocks,
|
|
||||||
buf_len = (uint)(command.buffer?.Length ?? 0),
|
|
||||||
command = command.command,
|
|
||||||
flags = command.flags,
|
|
||||||
timeout = timeout,
|
|
||||||
write = command.write
|
|
||||||
};
|
|
||||||
|
|
||||||
tmp = Marshal.StructureToByteArrayLittleEndian(cmd);
|
tmp = Marshal.StructureToByteArrayLittleEndian(cmd);
|
||||||
Array.Copy(tmp, 0, buf, off, tmp.Length);
|
Array.Copy(tmp, 0, buf, off, tmp.Length);
|
||||||
|
|
||||||
off += tmp.Length;
|
off += tmp.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Device.MmcSingleCommand command in commands)
|
foreach(Device.MmcSingleCommand command in commands.Where(command => (command.buffer?.Length ?? 0) != 0))
|
||||||
{
|
{
|
||||||
if((command.buffer?.Length ?? 0) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Array.Copy(command.buffer, 0, buf, off, command.buffer.Length);
|
Array.Copy(command.buffer, 0, buf, off, command.buffer.Length);
|
||||||
|
|
||||||
off += command.buffer.Length;
|
off += command.buffer.Length;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Aaru.CommonTypes;
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
@@ -61,11 +62,8 @@ namespace Aaru.Filesystems
|
|||||||
foreach(int offset in new[]
|
foreach(int offset in new[]
|
||||||
{
|
{
|
||||||
0, 0x200, 0x400, 0x600, 0x800, 0xA00
|
0, 0x200, 0x400, 0x600, 0x800, 0xA00
|
||||||
})
|
}.Where(offset => mdbSector.Length >= offset + 0x7C + 2))
|
||||||
{
|
{
|
||||||
if(mdbSector.Length < offset + 0x7C + 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, offset);
|
drSigWord = BigEndianBitConverter.ToUInt16(mdbSector, offset);
|
||||||
|
|
||||||
if(drSigWord != AppleCommon.HFS_MAGIC)
|
if(drSigWord != AppleCommon.HFS_MAGIC)
|
||||||
|
|||||||
@@ -1218,11 +1218,8 @@ namespace Aaru.DiscImages
|
|||||||
{
|
{
|
||||||
var lastTrackInSession = new Track();
|
var lastTrackInSession = new Track();
|
||||||
|
|
||||||
foreach(Track trk in Tracks.Where(trk => trk.TrackSession == leadOuts.Key))
|
foreach(Track trk in Tracks.Where(trk => trk.TrackSession == leadOuts.Key).Where(trk => trk.TrackSequence > lastTrackInSession.TrackSequence))
|
||||||
{
|
lastTrackInSession = trk;
|
||||||
if(trk.TrackSequence > lastTrackInSession.TrackSequence)
|
|
||||||
lastTrackInSession = trk;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lastTrackInSession.TrackSequence == 0 ||
|
if(lastTrackInSession.TrackSequence == 0 ||
|
||||||
lastTrackInSession.TrackEndSector == (ulong)leadOuts.Value - 1)
|
lastTrackInSession.TrackEndSector == (ulong)leadOuts.Value - 1)
|
||||||
|
|||||||
@@ -1388,11 +1388,8 @@ namespace Aaru.DiscImages
|
|||||||
{
|
{
|
||||||
var lastTrackInSession = new Track();
|
var lastTrackInSession = new Track();
|
||||||
|
|
||||||
foreach(Track trk in Tracks.Where(trk => trk.TrackSession == leadOuts.Key))
|
foreach(Track trk in Tracks.Where(trk => trk.TrackSession == leadOuts.Key).Where(trk => trk.TrackSequence > lastTrackInSession.TrackSequence))
|
||||||
{
|
lastTrackInSession = trk;
|
||||||
if(trk.TrackSequence > lastTrackInSession.TrackSequence)
|
|
||||||
lastTrackInSession = trk;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lastTrackInSession.TrackSequence == 0 ||
|
if(lastTrackInSession.TrackSequence == 0 ||
|
||||||
lastTrackInSession.TrackEndSector == (ulong)leadOuts.Value - 1)
|
lastTrackInSession.TrackEndSector == (ulong)leadOuts.Value - 1)
|
||||||
|
|||||||
@@ -77,22 +77,12 @@ namespace Aaru.DiscImages
|
|||||||
|
|
||||||
// Detect ProDOS skewed disks
|
// Detect ProDOS skewed disks
|
||||||
if(skewed)
|
if(skewed)
|
||||||
foreach(Apple2.RawSector sector in tracks[17].sectors)
|
foreach(bool isDos in from sector in tracks[17].sectors where sector.addressField.sector.SequenceEqual(new byte[]
|
||||||
|
{
|
||||||
|
170, 170
|
||||||
|
}) select Apple2.DecodeSector(sector) into sector0 where sector0 != null select sector0[0x01] == 17 && sector0[0x02] < 16 && sector0[0x27] <= 122 &&
|
||||||
|
sector0[0x34] == 35 && sector0[0x35] == 16 && sector0[0x36] == 0 && sector0[0x37] == 1)
|
||||||
{
|
{
|
||||||
if(!sector.addressField.sector.SequenceEqual(new byte[]
|
|
||||||
{
|
|
||||||
170, 170
|
|
||||||
}))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
byte[] sector0 = Apple2.DecodeSector(sector);
|
|
||||||
|
|
||||||
if(sector0 == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
bool isDos = sector0[0x01] == 17 && sector0[0x02] < 16 && sector0[0x27] <= 122 &&
|
|
||||||
sector0[0x34] == 35 && sector0[0x35] == 16 && sector0[0x36] == 0 && sector0[0x37] == 1;
|
|
||||||
|
|
||||||
if(isDos)
|
if(isDos)
|
||||||
skewing = _dosSkewing;
|
skewing = _dosSkewing;
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,8 @@ namespace Aaru.DiscImages
|
|||||||
{
|
{
|
||||||
var ctx = new Sha1Context();
|
var ctx = new Sha1Context();
|
||||||
|
|
||||||
foreach(IFilter filter in filters)
|
foreach(Stream stream in filters.Select(filter => filter.GetDataForkStream()))
|
||||||
{
|
{
|
||||||
Stream stream = filter.GetDataForkStream();
|
|
||||||
readBytes = 0;
|
readBytes = 0;
|
||||||
verifyBytes = new byte[verifySize];
|
verifyBytes = new byte[verifySize];
|
||||||
|
|
||||||
@@ -89,9 +88,8 @@ namespace Aaru.DiscImages
|
|||||||
{
|
{
|
||||||
var ctx = new Md5Context();
|
var ctx = new Md5Context();
|
||||||
|
|
||||||
foreach(IFilter filter in filters)
|
foreach(Stream stream in filters.Select(filter => filter.GetDataForkStream()))
|
||||||
{
|
{
|
||||||
Stream stream = filter.GetDataForkStream();
|
|
||||||
readBytes = 0;
|
readBytes = 0;
|
||||||
verifyBytes = new byte[verifySize];
|
verifyBytes = new byte[verifySize];
|
||||||
|
|
||||||
@@ -118,9 +116,8 @@ namespace Aaru.DiscImages
|
|||||||
{
|
{
|
||||||
var ctx = new Crc32Context();
|
var ctx = new Crc32Context();
|
||||||
|
|
||||||
foreach(IFilter filter in filters)
|
foreach(Stream stream in filters.Select(filter => filter.GetDataForkStream()))
|
||||||
{
|
{
|
||||||
Stream stream = filter.GetDataForkStream();
|
|
||||||
readBytes = 0;
|
readBytes = 0;
|
||||||
verifyBytes = new byte[verifySize];
|
verifyBytes = new byte[verifySize];
|
||||||
|
|
||||||
|
|||||||
@@ -613,14 +613,9 @@ namespace Aaru.DiscImages
|
|||||||
|
|
||||||
if(trackIndexes.TryGetValue((byte)tmpTrack.TrackSequence, out Dictionary<byte, int> indexes))
|
if(trackIndexes.TryGetValue((byte)tmpTrack.TrackSequence, out Dictionary<byte, int> indexes))
|
||||||
{
|
{
|
||||||
foreach(KeyValuePair<byte, int> trackIndex in indexes.OrderBy(i => i.Key))
|
foreach((byte index, int value) in indexes.OrderBy(i => i.Key).Where(trackIndex => trackIndex.Key > 1))
|
||||||
{
|
|
||||||
if(trackIndex.Key <= 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Untested as of 20210711
|
// Untested as of 20210711
|
||||||
tmpTrack.Indexes[trackIndex.Key] = trackIndex.Value;
|
tmpTrack.Indexes[index] = value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tmpTrack.TrackType == TrackType.Data)
|
if(tmpTrack.TrackType == TrackType.Data)
|
||||||
|
|||||||
Reference in New Issue
Block a user