REFACTOR: Use preferred braces style.

This commit is contained in:
2017-12-20 23:07:46 +00:00
parent 4158d64854
commit e9443388ee
120 changed files with 1016 additions and 1975 deletions

View File

@@ -205,7 +205,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(tracksArray[i].point >= 0xA0) continue;
if(!trackLengths.TryGetValue(tracksArray[i].point, out uint trkLen)) continue;
if(tracksArray[i].mode == AlcoholTrackMode.Dvd) { tracksArray[i].extraOffset = trkLen; }
if(tracksArray[i].mode == AlcoholTrackMode.Dvd) tracksArray[i].extraOffset = trkLen;
else
{
AlcoholTrackExtra extra = new AlcoholTrackExtra();
@@ -274,7 +274,6 @@ namespace DiscImageChef.Core.Devices.Dumping
if(header.type == AlcoholMediumType.Cd || header.type == AlcoholMediumType.Cdr ||
header.type == AlcoholMediumType.Cdrw)
{
foreach(AlcoholTrackExtra extra in extrasArray)
{
tmp = new byte[8];
@@ -284,7 +283,6 @@ namespace DiscImageChef.Core.Devices.Dumping
descriptorFile.Write(tmp, 0, tmp.Length);
Marshal.FreeHGlobal(trkxPtr);
}
}
if(bca != null && bca.Length > 0)
{
@@ -502,7 +500,7 @@ namespace DiscImageChef.Core.Devices.Dumping
AlcoholSession[] sess = sessions.ToArray();
for(int i = 0; i < sess.Length; i++) { if(sess[i].sessionSequence == session) sess[i].nonTrackBlocks++; }
for(int i = 0; i < sess.Length; i++) if(sess[i].sessionSequence == session) sess[i].nonTrackBlocks++;
sessions = new List<AlcoholSession>(sess);
}

View File

@@ -132,10 +132,7 @@ namespace DiscImageChef.Core.Devices.Dumping
Decoders.SCSI.MMC.DiscInformation.StandardDiscInformation? discInfo =
Decoders.SCSI.MMC.DiscInformation.Decode000b(cmdBuf);
if(discInfo.HasValue)
{
// If it is a read-only CD, check CD type if available
if(dskType == MediaType.CD)
{
switch(discInfo.Value.DiscType)
{
case 0x10:
@@ -145,8 +142,6 @@ namespace DiscImageChef.Core.Devices.Dumping
dskType = MediaType.CDROMXA;
break;
}
}
}
}
int sessions = 1;
@@ -172,15 +167,11 @@ namespace DiscImageChef.Core.Devices.Dumping
bool hasVideoTrack = false;
if(toc.HasValue)
{
foreach(FullTOC.TrackDataDescriptor track in toc.Value.TrackDescriptors)
{
if(track.TNO == 1 && ((TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrack ||
(TOC_CONTROL)(track.CONTROL & 0x0D) ==
TOC_CONTROL.DataTrackIncremental))
{
allFirstSessionTracksAreAudio &= firstTrackLastSession != 1;
}
TOC_CONTROL.DataTrackIncremental)) allFirstSessionTracksAreAudio &= firstTrackLastSession != 1;
if((TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrack ||
(TOC_CONTROL)(track.CONTROL & 0x0D) == TOC_CONTROL.DataTrackIncremental)
@@ -192,7 +183,6 @@ namespace DiscImageChef.Core.Devices.Dumping
hasVideoTrack |= track.ADR == 4;
}
}
if(hasDataTrack && hasAudioTrack && allFirstSessionTracksAreAudio && sessions == 2)
dskType = MediaType.CDPLUS;
@@ -204,7 +194,6 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Reading PMA");
sense = dev.ReadPma(out cmdBuf, out senseBuf, dev.Timeout, out duration);
if(!sense)
{
if(PMA.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -217,12 +206,10 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].PMA.Image, tmpBuf);
}
}
dumpLog.WriteLine("Reading CD-Text from Lead-In");
sense = dev.ReadCdText(out cmdBuf, out senseBuf, dev.Timeout, out duration);
if(!sense)
{
if(CDTextOnLeadIn.Decode(cmdBuf).HasValue)
{
tmpBuf = new byte[cmdBuf.Length - 4];
@@ -235,7 +222,6 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("SCSI Dump", sidecar.OpticalDisc[0].LeadInCdText.Image, tmpBuf);
}
}
}
}
@@ -259,7 +245,6 @@ namespace DiscImageChef.Core.Devices.Dumping
sessionsForAlcohol[i].StartTrack = ushort.MaxValue;
}
foreach(FullTOC.TrackDataDescriptor trk in toc.Value.TrackDescriptors)
{
if(trk.POINT > 0 && trk.POINT < 0xA0 && trk.SessionNumber <= sessionsForAlcohol.Length)
{
if(trk.POINT < sessionsForAlcohol[trk.SessionNumber - 1].StartTrack)
@@ -267,15 +252,12 @@ namespace DiscImageChef.Core.Devices.Dumping
if(trk.POINT > sessionsForAlcohol[trk.SessionNumber - 1].EndTrack)
sessionsForAlcohol[trk.SessionNumber - 1].EndTrack = trk.POINT;
}
}
alcohol.AddSessions(sessionsForAlcohol);
foreach(FullTOC.TrackDataDescriptor trk in toc.Value.TrackDescriptors)
{
alcohol.AddTrack((byte)((trk.ADR << 4) & trk.CONTROL), trk.TNO, trk.POINT, trk.Min, trk.Sec, trk.Frame,
trk.Zero, trk.PMIN, trk.PSEC, trk.PFRAME, trk.SessionNumber);
}
FullTOC.TrackDataDescriptor[] sortedTracks =
toc.Value.TrackDescriptors.OrderBy(track => track.POINT).ToArray();
@@ -283,9 +265,7 @@ namespace DiscImageChef.Core.Devices.Dumping
long lastSector = 0;
string lastMsf = null;
foreach(FullTOC.TrackDataDescriptor trk in sortedTracks)
{
if(trk.ADR == 1 || trk.ADR == 4)
{
if(trk.POINT >= 0x01 && trk.POINT <= 0x63)
{
TrackType track = new TrackType
@@ -345,8 +325,6 @@ namespace DiscImageChef.Core.Devices.Dumping
else lastMsf = string.Format("{0:D2}:{1:D2}:{2:D2}", pmin, psec, pframe);
lastSector = phour * 3600 * 75 + pmin * 60 * 75 + psec * 75 + pframe - 150;
}
}
}
TrackType[] tracks = trackList.ToArray();
for(int t = 1; t < tracks.Length; t++)
@@ -386,7 +364,7 @@ namespace DiscImageChef.Core.Devices.Dumping
return;
}
if(dumpRaw) { throw new NotImplementedException("Raw CD dumping not yet implemented"); }
if(dumpRaw) throw new NotImplementedException("Raw CD dumping not yet implemented");
else
{
// TODO: Check subchannel capabilities
@@ -472,7 +450,6 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpFile.Close();
if(leadInSectorsGood > 0)
{
sidecar.OpticalDisc[0].LeadIn = new BorderType[]
{
new BorderType
@@ -482,7 +459,6 @@ namespace DiscImageChef.Core.Devices.Dumping
Size = leadInSectorsTotal * blockSize
}
};
}
else File.Delete(outputPrefix + ".leadin.bin");
DicConsole.WriteLine();
@@ -602,13 +578,11 @@ namespace DiscImageChef.Core.Devices.Dumping
ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, blocksToRead, true);
if(separateSubchannel)
{
for(int b = 0; b < blocksToRead; b++)
{
dumpFile.Write(readBuffer, (int)(0 + b * blockSize), sectorSize);
subFile.Write(readBuffer, (int)(sectorSize + b * blockSize), (int)subSize);
}
}
else dumpFile.Write(readBuffer);
}
else
@@ -644,7 +618,6 @@ namespace DiscImageChef.Core.Devices.Dumping
{
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00
}))
{
switch(readBuffer[15])
{
case 0:
@@ -660,7 +633,6 @@ namespace DiscImageChef.Core.Devices.Dumping
checkedDataFormat = true;
break;
}
}
}
#pragma warning disable IDE0004 // Remove Unnecessary Cast
@@ -812,7 +784,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); }
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
runningPersistent = true;
if(!sense && !dev.Error)
@@ -833,7 +805,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); }
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
}
DicConsole.WriteLine();

View File

@@ -233,15 +233,12 @@ namespace DiscImageChef.Core.Devices.Dumping
sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current,
0x3F, 0xFF, 5, out duration);
if(!sense || dev.Error)
{
sense = dev.ModeSense10(out cmdBuf, out senseBuf, false, true,
ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out duration);
}
Decoders.SCSI.Modes.DecodedMode? decMode = null;
if(!sense && !dev.Error)
{
if(Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.ScsiType).HasValue)
{
decMode = Decoders.SCSI.Modes.DecodeMode10(cmdBuf, dev.ScsiType);
@@ -253,7 +250,6 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense10.Image, cmdBuf);
}
}
dumpLog.WriteLine("Requesting MODE SENSE (6).");
sense = dev.ModeSense6(out cmdBuf, out senseBuf, false, ScsiModeSensePageControl.Current, 0x3F,
@@ -264,7 +260,6 @@ namespace DiscImageChef.Core.Devices.Dumping
if(sense || dev.Error) sense = dev.ModeSense(out cmdBuf, out senseBuf, 5, out duration);
if(!sense && !dev.Error)
{
if(Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.ScsiType).HasValue)
{
decMode = Decoders.SCSI.Modes.DecodeMode6(cmdBuf, dev.ScsiType);
@@ -276,7 +271,6 @@ namespace DiscImageChef.Core.Devices.Dumping
};
DataFile.WriteTo("SCSI Dump", sidecar.BlockMedia[0].SCSI.ModeSense.Image, cmdBuf);
}
}
if(decMode.HasValue)
{
@@ -295,18 +289,12 @@ namespace DiscImageChef.Core.Devices.Dumping
uint longBlockSize = scsiReader.LongBlockSize;
if(dumpRaw)
{
if(blockSize == longBlockSize)
{
if(!scsiReader.CanReadRaw)
{
DicConsole.ErrorWriteLine("Device doesn't seem capable of reading raw data from media.");
}
if(!scsiReader.CanReadRaw) DicConsole.ErrorWriteLine("Device doesn't seem capable of reading raw data from media.");
else
{
DicConsole
.ErrorWriteLine("Device is capable of reading raw data but I've been unable to guess correct sector size.");
}
if(!force)
{
@@ -330,7 +318,6 @@ namespace DiscImageChef.Core.Devices.Dumping
physicalBlockSize = longBlockSize;
blockSize = longBlockSize;
}
}
DicConsole.WriteLine("Reading {0} sectors at a time.", blocksToRead);
@@ -548,7 +535,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); }
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
runningPersistent = true;
if(!sense && !dev.Error)
@@ -569,7 +556,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); }
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
}
DicConsole.WriteLine();
@@ -662,7 +649,6 @@ namespace DiscImageChef.Core.Devices.Dumping
partitions[i].Scheme);
foreach(Filesystem plugin in plugins.PluginsList.Values)
{
try
{
if(plugin.Identify(imageFormat, partitions[i]))
@@ -686,7 +672,6 @@ namespace DiscImageChef.Core.Devices.Dumping
{
//DicConsole.DebugWriteLine("Dump-media command", "Plugin {0} crashed", _plugin.Name);
}
}
if(lstFs.Count > 0) xmlFileSysInfo[i].FileSystems = lstFs.ToArray();
}
@@ -702,7 +687,6 @@ namespace DiscImageChef.Core.Devices.Dumping
new Partition {Name = "Whole device", Length = blocks, Size = blocks * blockSize};
foreach(Filesystem plugin in plugins.PluginsList.Values)
{
try
{
if(plugin.Identify(imageFormat, wholePart))
@@ -724,7 +708,6 @@ namespace DiscImageChef.Core.Devices.Dumping
{
//DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name);
}
}
if(lstFs.Count > 0) xmlFileSysInfo[0].FileSystems = lstFs.ToArray();
}
@@ -820,12 +803,10 @@ namespace DiscImageChef.Core.Devices.Dumping
Value = outputPrefix + ".bin"
};
if(!dev.IsRemovable || dev.IsUsb)
{
if(dev.Type == DeviceType.ATAPI) sidecar.BlockMedia[0].Interface = "ATAPI";
else if(dev.IsUsb) sidecar.BlockMedia[0].Interface = "USB";
else if(dev.IsFireWire) sidecar.BlockMedia[0].Interface = "FireWire";
else sidecar.BlockMedia[0].Interface = "SCSI";
}
sidecar.BlockMedia[0].LogicalBlocks = (long)blocks;
sidecar.BlockMedia[0].PhysicalBlockSize = (int)physicalBlockSize;
sidecar.BlockMedia[0].LogicalBlockSize = (int)logicalBlockSize;

View File

@@ -604,7 +604,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{
List<ulong> tmpList = new List<ulong>();
foreach(ulong ur in resume.BadBlocks) { for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i); }
foreach(ulong ur in resume.BadBlocks) for(ulong i = ur; i < ur + blocksToRead; i++) tmpList.Add(i);
tmpList.Sort();
@@ -732,7 +732,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); }
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
runningPersistent = true;
if(!sense && !dev.Error)
@@ -753,7 +753,7 @@ namespace DiscImageChef.Core.Devices.Dumping
dumpLog.WriteLine("Sending MODE SELECT to drive.");
sense = dev.ModeSelect(md6, out senseBuf, true, false, dev.Timeout, out duration);
if(sense) { sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration); }
if(sense) sense = dev.ModeSelect10(md10, out senseBuf, true, false, dev.Timeout, out duration);
}
DicConsole.WriteLine();
@@ -848,7 +848,6 @@ namespace DiscImageChef.Core.Devices.Dumping
partitions[i].Scheme);
foreach(Filesystem plugin in plugins.PluginsList.Values)
{
try
{
if(plugin.Identify(imageFormat, partitions[i]))
@@ -872,7 +871,6 @@ namespace DiscImageChef.Core.Devices.Dumping
{
//DicConsole.DebugWriteLine("Dump-media command", "Plugin {0} crashed", _plugin.Name);
}
}
if(lstFs.Count > 0) xmlFileSysInfo[i].FileSystems = lstFs.ToArray();
}
@@ -888,7 +886,6 @@ namespace DiscImageChef.Core.Devices.Dumping
new Partition {Name = "Whole device", Length = blocks, Size = blocks * blockSize};
foreach(Filesystem plugin in plugins.PluginsList.Values)
{
try
{
if(plugin.Identify(imageFormat, wholePart))
@@ -910,7 +907,6 @@ namespace DiscImageChef.Core.Devices.Dumping
{
//DicConsole.DebugWriteLine("Create-sidecar command", "Plugin {0} crashed", _plugin.Name);
}
}
if(lstFs.Count > 0) xmlFileSysInfo[0].FileSystems = lstFs.ToArray();
}