From d4bfbf2caeb36926b0f105345a0105643ddbc324 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 23 Dec 2017 04:48:17 +0000 Subject: [PATCH] REFACTOR: Final cleanup of DiscImageChef. --- DiscImageChef/Commands/Checksum.cs | 3 +- DiscImageChef/Commands/Compare.cs | 28 ++- DiscImageChef/Commands/CreateSidecar.cs | 14 +- DiscImageChef/Commands/DeviceInfo.cs | 290 ++++++++++-------------- DiscImageChef/Commands/DeviceReport.cs | 6 +- DiscImageChef/Commands/DumpMedia.cs | 3 +- DiscImageChef/Commands/Entropy.cs | 6 +- DiscImageChef/Commands/ExtractFiles.cs | 208 ++++++++++------- DiscImageChef/Commands/ListEncodings.cs | 29 ++- DiscImageChef/Commands/Ls.cs | 12 +- DiscImageChef/Commands/MediaInfo.cs | 174 +++++++------- DiscImageChef/Commands/MediaScan.cs | 3 +- DiscImageChef/Commands/PrintHex.cs | 4 +- DiscImageChef/Commands/Statistics.cs | 7 +- DiscImageChef/Commands/Verify.cs | 6 +- DiscImageChef/Main.cs | 254 +++++++++++---------- DiscImageChef/Progress.cs | 2 +- 17 files changed, 535 insertions(+), 514 deletions(-) diff --git a/DiscImageChef/Commands/Checksum.cs b/DiscImageChef/Commands/Checksum.cs index 8625f159..bb81bd56 100644 --- a/DiscImageChef/Commands/Checksum.cs +++ b/DiscImageChef/Commands/Checksum.cs @@ -155,8 +155,7 @@ namespace DiscImageChef.Commands doneSectors += sectors - doneSectors; } - if(options.WholeDisc) - mediaChecksum?.Update(sector); + if(options.WholeDisc) mediaChecksum?.Update(sector); if(options.SeparatedTracks) trackChecksum?.Update(sector); } diff --git a/DiscImageChef/Commands/Compare.cs b/DiscImageChef/Commands/Compare.cs index a52e4e4d..54f89f1f 100644 --- a/DiscImageChef/Commands/Compare.cs +++ b/DiscImageChef/Commands/Compare.cs @@ -128,7 +128,9 @@ namespace DiscImageChef.Commands image1Info.ImageHasPartitions = input1Format.ImageHasPartitions(); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { image1Sessions = input1Format.GetSessions(); } - catch { // ignored + catch + { + // ignored } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body image1Info.ImageHasSessions |= image1Sessions.Count > 0; @@ -180,16 +182,20 @@ namespace DiscImageChef.Commands image1DiskTags.Add(disktag, temparray); } #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } image2Info.ImageHasPartitions = input2Format.ImageHasPartitions(); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { image2Sessions = input2Format.GetSessions(); } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body image2Info.ImageHasSessions |= image2Sessions.Count > 0; image2Info.ImageSize = input2Format.GetImageSize(); @@ -240,8 +246,10 @@ namespace DiscImageChef.Commands image2DiskTags.Add(disktag, temparray); } #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } @@ -462,8 +470,10 @@ namespace DiscImageChef.Commands } } #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body } diff --git a/DiscImageChef/Commands/CreateSidecar.cs b/DiscImageChef/Commands/CreateSidecar.cs index 89e99e07..f7120c3d 100644 --- a/DiscImageChef/Commands/CreateSidecar.cs +++ b/DiscImageChef/Commands/CreateSidecar.cs @@ -133,8 +133,7 @@ namespace DiscImageChef.Commands FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"), FileMode.CreateNew); - XmlSerializer xmlSer = - new XmlSerializer(typeof(CICMMetadataType)); + XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType)); xmlSer.Serialize(xmlFs, sidecar); xmlFs.Close(); @@ -155,7 +154,8 @@ namespace DiscImageChef.Commands } string[] contents = Directory.GetFiles(options.InputFile, "*", SearchOption.TopDirectoryOnly); - List files = contents.Where(file => new FileInfo(file).Length % options.BlockSize == 0).ToList(); + List files = contents.Where(file => new FileInfo(file).Length % options.BlockSize == 0) + .ToList(); files.Sort(StringComparer.CurrentCultureIgnoreCase); @@ -169,17 +169,13 @@ namespace DiscImageChef.Commands FileStream(Path.Combine(Path.GetDirectoryName(options.InputFile) ?? throw new InvalidOperationException(), Path.GetFileNameWithoutExtension(options.InputFile) + ".cicm.xml"), FileMode.CreateNew); - XmlSerializer xmlSer = - new XmlSerializer(typeof(CICMMetadataType)); + XmlSerializer xmlSer = new XmlSerializer(typeof(CICMMetadataType)); xmlSer.Serialize(xmlFs, sidecar); xmlFs.Close(); Core.Statistics.AddCommand("create-sidecar"); } - else - { - DicConsole.ErrorWriteLine("The specified input file cannot be found."); - } + else DicConsole.ErrorWriteLine("The specified input file cannot be found."); } } } \ No newline at end of file diff --git a/DiscImageChef/Commands/DeviceInfo.cs b/DiscImageChef/Commands/DeviceInfo.cs index 3e66e813..431f4d87 100644 --- a/DiscImageChef/Commands/DeviceInfo.cs +++ b/DiscImageChef/Commands/DeviceInfo.cs @@ -53,7 +53,8 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Device-Info command", "--output-prefix={0}", options.OutputPrefix); if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; + char.IsLetter(options.DevicePath[0])) + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); @@ -105,9 +106,7 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", CIS.PrettifyDeviceGeometryTuple(tuple)); break; case TupleCodes.CISTPL_MANFID: - DicConsole.WriteLine("{0}", - CIS - .PrettifyManufacturerIdentificationTuple(tuple)); + DicConsole.WriteLine("{0}", CIS.PrettifyManufacturerIdentificationTuple(tuple)); break; case TupleCodes.CISTPL_VERS_1: DicConsole.WriteLine("{0}", CIS.PrettifyLevel1VersionTuple(tuple)); @@ -284,21 +283,21 @@ namespace DiscImageChef.Commands sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(sense) continue; - DicConsole.WriteLine("ASCII Page {0:X2}h: {1}", page, - EVPD.DecodeASCIIPage(inqBuf)); + DicConsole.WriteLine("ASCII Page {0:X2}h: {1}", page, EVPD.DecodeASCIIPage(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x80) { sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(sense) continue; - DicConsole.WriteLine("Unit Serial Number: {0}", - EVPD.DecodePage80(inqBuf)); + DicConsole.WriteLine("Unit Serial Number: {0}", EVPD.DecodePage80(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x81) { @@ -307,7 +306,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_81(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x82) { @@ -317,7 +317,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("ASCII implemented operating definitions: {0}", EVPD.DecodePage82(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x83) { @@ -326,7 +327,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_83(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x84) { @@ -335,7 +337,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_84(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x85) { @@ -344,7 +347,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_85(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x86) { @@ -353,7 +357,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_86(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0x89) { @@ -362,7 +367,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_89(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xB0) { @@ -371,7 +377,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_B0(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xB1) { @@ -381,7 +388,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Manufacturer-assigned Serial Number: {0}", EVPD.DecodePageB1(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xB2) { @@ -391,7 +399,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("TapeAlert Supported Flags Bitmap: 0x{0:X16}", EVPD.DecodePageB2(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xB3) { @@ -401,7 +410,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Automation Device Serial Number: {0}", EVPD.DecodePageB3(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xB4) { @@ -411,7 +421,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Data Transfer Device Element Address: 0x{0}", EVPD.DecodePageB4(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xC0 && StringHandlers @@ -423,7 +434,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_C0_Quantum(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xC0 && StringHandlers @@ -435,7 +447,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_C0_Seagate(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xC0 && StringHandlers @@ -447,7 +460,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_C0_IBM(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xC1 && StringHandlers @@ -459,7 +473,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("{0}", EVPD.PrettifyPage_C1_IBM(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if((page == 0xC0 || page == 0xC1) && StringHandlers @@ -469,10 +484,10 @@ namespace DiscImageChef.Commands sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(sense) continue; - DicConsole.WriteLine("{0}", - EVPD.PrettifyPage_C0_C1_Certance(inqBuf)); + DicConsole.WriteLine("{0}", EVPD.PrettifyPage_C0_C1_Certance(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if( (page == 0xC2 || page == 0xC3 || page == 0xC4 || page == 0xC5 || page == 0xC6) && @@ -482,11 +497,10 @@ namespace DiscImageChef.Commands sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(sense) continue; - DicConsole.WriteLine("{0}", - EVPD - .PrettifyPage_C2_C3_C4_C5_C6_Certance(inqBuf)); + DicConsole.WriteLine("{0}", EVPD.PrettifyPage_C2_C3_C4_C5_C6_Certance(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if((page == 0xC0 || page == 0xC1 || page == 0xC2 || page == 0xC3 || page == 0xC4 || page == 0xC5) && @@ -497,10 +511,10 @@ namespace DiscImageChef.Commands sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(sense) continue; - DicConsole.WriteLine("{0}", - EVPD.PrettifyPage_C0_to_C5_HP(inqBuf)); + DicConsole.WriteLine("{0}", EVPD.PrettifyPage_C0_to_C5_HP(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else if(page == 0xDF && StringHandlers @@ -510,10 +524,10 @@ namespace DiscImageChef.Commands sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(sense) continue; - DicConsole.WriteLine("{0}", - EVPD.PrettifyPage_DF_Certance(inqBuf)); + DicConsole.WriteLine("{0}", EVPD.PrettifyPage_DF_Certance(inqBuf)); DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } else { @@ -525,16 +539,16 @@ namespace DiscImageChef.Commands sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page); if(!sense) DataFile.WriteTo("Device-Info command", options.OutputPrefix, - $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", inqBuf); + $"_scsi_evpd_{page:X2}h.bin", $"SCSI INQUIRY EVPD {page:X2}h", + inqBuf); } } Modes.DecodedMode? decMode = null; - PeripheralDeviceTypes devType = - (PeripheralDeviceTypes)inq.Value.PeripheralDeviceType; + PeripheralDeviceTypes devType = (PeripheralDeviceTypes)inq.Value.PeripheralDeviceType; - sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, - 0x3F, 0xFF, 5, out _); + sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, + ScsiModeSensePageControl.Current, 0x3F, 0xFF, 5, out _); if(sense || dev.Error) sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _); @@ -568,10 +582,8 @@ namespace DiscImageChef.Commands { case 0x00: { - if(devType == PeripheralDeviceTypes.MultiMediaDevice && - page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_00_SFF(page.PageResponse)); + if(devType == PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0) + DicConsole.WriteLine(Modes.PrettifyModePage_00_SFF(page.PageResponse)); else { if(page.Subpage != 0) @@ -588,12 +600,8 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) if(devType == PeripheralDeviceTypes.MultiMediaDevice) - DicConsole.WriteLine(Modes - .PrettifyModePage_01_MMC(page - .PageResponse)); - else - DicConsole.WriteLine(Modes - .PrettifyModePage_01(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_01_MMC(page.PageResponse)); + else DicConsole.WriteLine(Modes.PrettifyModePage_01(page.PageResponse)); else goto default; break; @@ -601,8 +609,7 @@ namespace DiscImageChef.Commands case 0x02: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_02(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_02(page.PageResponse)); else goto default; break; @@ -610,8 +617,7 @@ namespace DiscImageChef.Commands case 0x03: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_03(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_03(page.PageResponse)); else goto default; break; @@ -619,8 +625,7 @@ namespace DiscImageChef.Commands case 0x04: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_04(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_04(page.PageResponse)); else goto default; break; @@ -628,8 +633,7 @@ namespace DiscImageChef.Commands case 0x05: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_05(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_05(page.PageResponse)); else goto default; break; @@ -637,8 +641,7 @@ namespace DiscImageChef.Commands case 0x06: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_06(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_06(page.PageResponse)); else goto default; break; @@ -647,12 +650,8 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) if(devType == PeripheralDeviceTypes.MultiMediaDevice) - DicConsole.WriteLine(Modes - .PrettifyModePage_07_MMC(page - .PageResponse)); - else - DicConsole.WriteLine(Modes - .PrettifyModePage_07(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_07_MMC(page.PageResponse)); + else DicConsole.WriteLine(Modes.PrettifyModePage_07(page.PageResponse)); else goto default; break; @@ -660,8 +659,7 @@ namespace DiscImageChef.Commands case 0x08: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_08(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_08(page.PageResponse)); else goto default; break; @@ -669,11 +667,9 @@ namespace DiscImageChef.Commands case 0x0A: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_0A(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_0A(page.PageResponse)); else if(page.Subpage == 1) - DicConsole.WriteLine(Modes - .PrettifyModePage_0A_S01(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_0A_S01(page.PageResponse)); else goto default; break; @@ -681,8 +677,7 @@ namespace DiscImageChef.Commands case 0x0B: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_0B(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_0B(page.PageResponse)); else goto default; break; @@ -690,8 +685,7 @@ namespace DiscImageChef.Commands case 0x0D: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_0D(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_0D(page.PageResponse)); else goto default; break; @@ -699,8 +693,7 @@ namespace DiscImageChef.Commands case 0x0E: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_0E(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_0E(page.PageResponse)); else goto default; break; @@ -708,8 +701,7 @@ namespace DiscImageChef.Commands case 0x0F: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_0F(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_0F(page.PageResponse)); else goto default; break; @@ -718,12 +710,8 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) if(devType == PeripheralDeviceTypes.SequentialAccess) - DicConsole.WriteLine(Modes - .PrettifyModePage_10_SSC(page - .PageResponse)); - else - DicConsole.WriteLine(Modes - .PrettifyModePage_10(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_10_SSC(page.PageResponse)); + else DicConsole.WriteLine(Modes.PrettifyModePage_10(page.PageResponse)); else goto default; break; @@ -731,8 +719,7 @@ namespace DiscImageChef.Commands case 0x11: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_11(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_11(page.PageResponse)); else goto default; break; @@ -742,9 +729,7 @@ namespace DiscImageChef.Commands case 0x14: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_12_13_14(page - .PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_12_13_14(page.PageResponse)); else goto default; break; @@ -752,11 +737,9 @@ namespace DiscImageChef.Commands case 0x1A: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_1A(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_1A(page.PageResponse)); else if(page.Subpage == 1) - DicConsole.WriteLine(Modes - .PrettifyModePage_1A_S01(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_1A_S01(page.PageResponse)); else goto default; break; @@ -764,8 +747,7 @@ namespace DiscImageChef.Commands case 0x1B: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_1B(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_1B(page.PageResponse)); else goto default; break; @@ -774,15 +756,10 @@ namespace DiscImageChef.Commands { if(page.Subpage == 0) if(devType == PeripheralDeviceTypes.MultiMediaDevice) - DicConsole.WriteLine(Modes - .PrettifyModePage_1C_SFF(page - .PageResponse)); - else - DicConsole.WriteLine(Modes - .PrettifyModePage_1C(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_1C_SFF(page.PageResponse)); + else DicConsole.WriteLine(Modes.PrettifyModePage_1C(page.PageResponse)); else if(page.Subpage == 1) - DicConsole.WriteLine(Modes - .PrettifyModePage_1C_S01(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_1C_S01(page.PageResponse)); else goto default; break; @@ -790,8 +767,7 @@ namespace DiscImageChef.Commands case 0x1D: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_1D(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_1D(page.PageResponse)); else goto default; break; @@ -799,10 +775,7 @@ namespace DiscImageChef.Commands case 0x21: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "CERTANCE" - ) - DicConsole.WriteLine(Modes - .PrettifyCertanceModePage_21(page - .PageResponse)); + ) DicConsole.WriteLine(Modes.PrettifyCertanceModePage_21(page.PageResponse)); else goto default; break; @@ -810,10 +783,7 @@ namespace DiscImageChef.Commands case 0x22: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "CERTANCE" - ) - DicConsole.WriteLine(Modes - .PrettifyCertanceModePage_22(page - .PageResponse)); + ) DicConsole.WriteLine(Modes.PrettifyCertanceModePage_22(page.PageResponse)); else goto default; break; @@ -821,8 +791,7 @@ namespace DiscImageChef.Commands case 0x24: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "IBM") - DicConsole.WriteLine(Modes - .PrettifyIBMModePage_24(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyIBMModePage_24(page.PageResponse)); else goto default; break; @@ -830,8 +799,7 @@ namespace DiscImageChef.Commands case 0x2A: { if(page.Subpage == 0) - DicConsole.WriteLine(Modes - .PrettifyModePage_2A(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyModePage_2A(page.PageResponse)); else goto default; break; @@ -839,8 +807,7 @@ namespace DiscImageChef.Commands case 0x2F: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "IBM") - DicConsole.WriteLine(Modes - .PrettifyIBMModePage_2F(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyIBMModePage_2F(page.PageResponse)); else goto default; break; @@ -856,8 +823,7 @@ namespace DiscImageChef.Commands case 0x3B: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") - DicConsole.WriteLine(Modes - .PrettifyHPModePage_3B(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyHPModePage_3B(page.PageResponse)); else goto default; break; @@ -865,8 +831,7 @@ namespace DiscImageChef.Commands case 0x3C: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") - DicConsole.WriteLine(Modes - .PrettifyHPModePage_3C(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyHPModePage_3C(page.PageResponse)); else goto default; break; @@ -874,11 +839,9 @@ namespace DiscImageChef.Commands case 0x3D: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "IBM") - DicConsole.WriteLine(Modes - .PrettifyIBMModePage_3D(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyIBMModePage_3D(page.PageResponse)); else if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") - DicConsole.WriteLine(Modes - .PrettifyHPModePage_3D(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyHPModePage_3D(page.PageResponse)); else goto default; break; @@ -886,12 +849,9 @@ namespace DiscImageChef.Commands case 0x3E: { if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "FUJITSU") - DicConsole.WriteLine(Modes - .PrettifyFujitsuModePage_3E(page - .PageResponse)); + DicConsole.WriteLine(Modes.PrettifyFujitsuModePage_3E(page.PageResponse)); else if(StringHandlers.CToString(inq.Value.VendorIdentification).Trim() == "HP") - DicConsole.WriteLine(Modes - .PrettifyHPModePage_3E(page.PageResponse)); + DicConsole.WriteLine(Modes.PrettifyHPModePage_3E(page.PageResponse)); else goto default; break; @@ -907,20 +867,20 @@ namespace DiscImageChef.Commands } } - switch(devType) { + switch(devType) + { case PeripheralDeviceTypes.MultiMediaDevice: sense = dev.GetConfiguration(out byte[] confBuf, out senseBuf, dev.Timeout, out _); if(!sense) { - DataFile.WriteTo("Device-Info command", options.OutputPrefix, "_mmc_getconfiguration.bin", - "MMC GET CONFIGURATION", confBuf); + DataFile.WriteTo("Device-Info command", options.OutputPrefix, + "_mmc_getconfiguration.bin", "MMC GET CONFIGURATION", confBuf); - Features.SeparatedFeatures ftr = - Features.Separate(confBuf); + Features.SeparatedFeatures ftr = Features.Separate(confBuf); - DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes", - ftr.DataLength); + DicConsole.DebugWriteLine("Device-Info command", + "GET CONFIGURATION length is {0} bytes", ftr.DataLength); DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION current profile is {0:X4}h", ftr.CurrentProfile); @@ -1188,8 +1148,9 @@ namespace DiscImageChef.Commands plxtBuf = new byte[256 * 4]; for(byte i = 0; i < 4; i++) { - plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, out senseBuf, i, 256, - dev.Timeout, out _); + plxtSense = dev.PlextorReadEepromBlock(out byte[] plxtBufSmall, + out senseBuf, i, 256, dev.Timeout, + out _); if(plxtSense) break; Array.Copy(plxtBufSmall, 0, plxtBuf, i * 256, 256); @@ -1249,8 +1210,8 @@ namespace DiscImageChef.Commands } } - plxtSense = dev.PlextorGetPoweRec(out senseBuf, out bool plxtPwrRecEnabled, out ushort plxtPwrRecSpeed, - dev.Timeout, out _); + plxtSense = dev.PlextorGetPoweRec(out senseBuf, out bool plxtPwrRecEnabled, + out ushort plxtPwrRecSpeed, dev.Timeout, out _); if(!plxtSense) { DicConsole.Write("Drive supports PoweRec"); @@ -1263,8 +1224,8 @@ namespace DiscImageChef.Commands else DicConsole.WriteLine("."); plxtSense = dev.PlextorGetSpeeds(out senseBuf, out ushort plxtPwrRecSelected, - out ushort plxtPwrRecMax, out ushort plxtPwrRecLast, dev.Timeout, - out _); + out ushort plxtPwrRecMax, + out ushort plxtPwrRecLast, dev.Timeout, out _); if(!plxtSense) { @@ -1303,7 +1264,8 @@ namespace DiscImageChef.Commands if(plxtBuf[4] > 0) DicConsole.WriteLine("\tCD write speed limited to {0}x", plxtBuf[4]); if(plxtBuf[6] > 0) - DicConsole.WriteLine("\tTray eject speed limited to {0}", -(plxtBuf[6] + 48)); + DicConsole.WriteLine("\tTray eject speed limited to {0}", + -(plxtBuf[6] + 48)); if(plxtBuf[7] > 0) DicConsole.WriteLine("\tTray eject speed limited to {0}", plxtBuf[7] - 47); } @@ -1333,8 +1295,7 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Drive currently forces single session"); } - plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, false, dev.Timeout, - out _); + plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, false, dev.Timeout, out _); if(!plxtSense) DicConsole.WriteLine("Drive supports Plextor VariRec"); if(plxtDvd) @@ -1357,8 +1318,8 @@ namespace DiscImageChef.Commands #endregion Plextor if(inq.Value.KreonPresent) - { - if(!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout, out _)) + if(!dev.KreonGetFeatureList(out senseBuf, out KreonFeatures krFeatures, dev.Timeout, + out _)) { DicConsole.WriteLine("Drive has kreon firmware:"); if(krFeatures.HasFlag(KreonFeatures.ChallengeResponse)) @@ -1382,18 +1343,16 @@ namespace DiscImageChef.Commands if(krFeatures.HasFlag(KreonFeatures.ErrorSkipping)) DicConsole.WriteLine("\tCan skip read errors"); } - } break; case PeripheralDeviceTypes.SequentialAccess: sense = dev.ReadBlockLimits(out byte[] seqBuf, out senseBuf, dev.Timeout, out _); if(sense) - DicConsole.ErrorWriteLine("READ BLOCK LIMITS:\n{0}", - Sense.PrettifySense(senseBuf)); + DicConsole.ErrorWriteLine("READ BLOCK LIMITS:\n{0}", Sense.PrettifySense(senseBuf)); else { - DataFile.WriteTo("Device-Info command", options.OutputPrefix, "_ssc_readblocklimits.bin", - "SSC READ BLOCK LIMITS", seqBuf); + DataFile.WriteTo("Device-Info command", options.OutputPrefix, + "_ssc_readblocklimits.bin", "SSC READ BLOCK LIMITS", seqBuf); DicConsole.WriteLine("Block limits for device:"); DicConsole.WriteLine(BlockLimits.Prettify(seqBuf)); } @@ -1406,8 +1365,7 @@ namespace DiscImageChef.Commands { DataFile.WriteTo("Device-Info command", options.OutputPrefix, "_ssc_reportdensitysupport.bin", "SSC REPORT DENSITY SUPPORT", seqBuf); - DensitySupport.DensitySupportHeader? dens = - DensitySupport.DecodeDensity(seqBuf); + DensitySupport.DensitySupportHeader? dens = DensitySupport.DecodeDensity(seqBuf); if(dens.HasValue) { DicConsole.WriteLine("Densities supported by device:"); @@ -1415,8 +1373,7 @@ namespace DiscImageChef.Commands } } - sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, true, false, dev.Timeout, - out _); + sense = dev.ReportDensitySupport(out seqBuf, out senseBuf, true, false, dev.Timeout, out _); if(sense) DicConsole.ErrorWriteLine("REPORT DENSITY SUPPORT (MEDIUM):\n{0}", Sense.PrettifySense(senseBuf)); @@ -1425,8 +1382,7 @@ namespace DiscImageChef.Commands DataFile.WriteTo("Device-Info command", options.OutputPrefix, "_ssc_reportdensitysupport_medium.bin", "SSC REPORT DENSITY SUPPORT (MEDIUM)", seqBuf); - DensitySupport.MediaTypeSupportHeader? meds = - DensitySupport.DecodeMediumType(seqBuf); + DensitySupport.MediaTypeSupportHeader? meds = DensitySupport.DecodeMediumType(seqBuf); if(meds.HasValue) { DicConsole.WriteLine("Medium types supported by device:"); diff --git a/DiscImageChef/Commands/DeviceReport.cs b/DiscImageChef/Commands/DeviceReport.cs index fcad3bd4..408383a3 100644 --- a/DiscImageChef/Commands/DeviceReport.cs +++ b/DiscImageChef/Commands/DeviceReport.cs @@ -50,7 +50,8 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Device-Report command", "--device={0}", options.DevicePath); if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; + char.IsLetter(options.DevicePath[0])) + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); @@ -94,8 +95,7 @@ namespace DiscImageChef.Commands FileStream xmlFs = new FileStream(xmlFile, FileMode.Create); - XmlSerializer xmlSer = - new XmlSerializer(typeof(Metadata.DeviceReport)); + XmlSerializer xmlSer = new XmlSerializer(typeof(Metadata.DeviceReport)); xmlSer.Serialize(xmlFs, report); xmlFs.Close(); Core.Statistics.AddCommand("device-report"); diff --git a/DiscImageChef/Commands/DumpMedia.cs b/DiscImageChef/Commands/DumpMedia.cs index eec29cfd..cc33aa43 100644 --- a/DiscImageChef/Commands/DumpMedia.cs +++ b/DiscImageChef/Commands/DumpMedia.cs @@ -75,7 +75,8 @@ namespace DiscImageChef.Commands } if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; + char.IsLetter(options.DevicePath[0])) + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); diff --git a/DiscImageChef/Commands/Entropy.cs b/DiscImageChef/Commands/Entropy.cs index 0b7a17a7..b74ec03e 100644 --- a/DiscImageChef/Commands/Entropy.cs +++ b/DiscImageChef/Commands/Entropy.cs @@ -108,7 +108,8 @@ namespace DiscImageChef.Commands trackSize += (ulong)sector.LongLength; } - entropy += entTable.Select(l => (double)l / (double)trackSize).Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum(); + entropy += entTable.Select(l => (double)l / (double)trackSize) + .Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum(); DicConsole.WriteLine("Entropy for track {0} is {1:F4}.", currentTrack.TrackSequence, entropy); @@ -154,7 +155,8 @@ namespace DiscImageChef.Commands diskSize += (ulong)sector.LongLength; } - entropy += entTable.Select(l => (double)l / (double)diskSize).Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum(); + entropy += entTable.Select(l => (double)l / (double)diskSize) + .Select(frequency => -(frequency * Math.Log(frequency, 2))).Sum(); DicConsole.WriteLine(); diff --git a/DiscImageChef/Commands/ExtractFiles.cs b/DiscImageChef/Commands/ExtractFiles.cs index 194a3564..abd09b7d 100644 --- a/DiscImageChef/Commands/ExtractFiles.cs +++ b/DiscImageChef/Commands/ExtractFiles.cs @@ -175,7 +175,10 @@ namespace DiscImageChef.Commands { FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFSType.VolumeName) ? "NO NAME" : fs.XmlFSType.VolumeName; + string volumeName = + string.IsNullOrEmpty(fs.XmlFSType.VolumeName) + ? "NO NAME" + : fs.XmlFSType.VolumeName; error = fs.Stat(entry, ref stat); if(error == Errno.NoError) @@ -197,44 +200,38 @@ namespace DiscImageChef.Commands Directory .CreateDirectory(Path.Combine(options.OutputDir, fs.XmlFSType.Type, - volumeName, - ".xattrs", + volumeName, ".xattrs", xattr)); outputPath = - Path.Combine(options.OutputDir, - fs.XmlFSType.Type, volumeName, - ".xattrs", xattr, entry); + Path.Combine(options.OutputDir, fs.XmlFSType.Type, + volumeName, ".xattrs", xattr, entry); if(!File.Exists(outputPath)) { outputFile = - new FileStream(outputPath, - FileMode.CreateNew, + new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None); outputFile.Write(xattrBuf, 0, xattrBuf.Length); outputFile.Close(); FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body - try + try { fi.CreationTimeUtc = stat.CreationTimeUtc; } + catch { - fi.CreationTimeUtc = stat.CreationTimeUtc; + // ignored } - catch { // ignored - } - try + try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } + catch { - fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; + // ignored } - catch { // ignored - } - try + try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } + catch { - fi.LastAccessTimeUtc = stat.AccessTimeUtc; + // ignored } - catch { // ignored - } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole .WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}", @@ -272,14 +269,20 @@ namespace DiscImageChef.Commands FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole.WriteLine("Written {0} bytes of file {1} to {2}", outBuf.Length, entry, outputPath); @@ -325,7 +328,10 @@ namespace DiscImageChef.Commands { FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFSType.VolumeName) ? "NO NAME" : fs.XmlFSType.VolumeName; + string volumeName = + string.IsNullOrEmpty(fs.XmlFSType.VolumeName) + ? "NO NAME" + : fs.XmlFSType.VolumeName; error = fs.Stat(entry, ref stat); if(error == Errno.NoError) @@ -346,8 +352,8 @@ namespace DiscImageChef.Commands Directory.CreateDirectory(Path.Combine(options.OutputDir, fs.XmlFSType.Type, - volumeName, - ".xattrs", xattr)); + volumeName, ".xattrs", + xattr)); outputPath = Path.Combine(options.OutputDir, fs.XmlFSType.Type, @@ -357,26 +363,30 @@ namespace DiscImageChef.Commands { outputFile = new FileStream(outputPath, FileMode.CreateNew, - FileAccess.ReadWrite, - FileShare.None); + FileAccess.ReadWrite, FileShare.None); outputFile.Write(xattrBuf, 0, xattrBuf.Length); outputFile.Close(); FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole .WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}", - xattrBuf.Length, xattr, entry, - outputPath); + xattrBuf.Length, xattr, entry, outputPath); } else DicConsole @@ -407,14 +417,20 @@ namespace DiscImageChef.Commands FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole.WriteLine("Written {0} bytes of file {1} to {2}", outBuf.Length, entry, outputPath); @@ -471,7 +487,10 @@ namespace DiscImageChef.Commands { FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFSType.VolumeName) ? "NO NAME" : fs.XmlFSType.VolumeName; + string volumeName = + string.IsNullOrEmpty(fs.XmlFSType.VolumeName) + ? "NO NAME" + : fs.XmlFSType.VolumeName; error = fs.Stat(entry, ref stat); if(error == Errno.NoError) @@ -492,8 +511,8 @@ namespace DiscImageChef.Commands Directory.CreateDirectory(Path.Combine(options.OutputDir, fs.XmlFSType.Type, - volumeName, - ".xattrs", xattr)); + volumeName, ".xattrs", + xattr)); outputPath = Path.Combine(options.OutputDir, fs.XmlFSType.Type, @@ -503,26 +522,30 @@ namespace DiscImageChef.Commands { outputFile = new FileStream(outputPath, FileMode.CreateNew, - FileAccess.ReadWrite, - FileShare.None); + FileAccess.ReadWrite, FileShare.None); outputFile.Write(xattrBuf, 0, xattrBuf.Length); outputFile.Close(); FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole .WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}", - xattrBuf.Length, xattr, entry, - outputPath); + xattrBuf.Length, xattr, entry, outputPath); } else DicConsole @@ -553,14 +576,20 @@ namespace DiscImageChef.Commands FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole.WriteLine("Written {0} bytes of file {1} to {2}", outBuf.Length, entry, outputPath); @@ -588,10 +617,8 @@ namespace DiscImageChef.Commands plugins.PluginsList.TryGetValue(idPlugins[0], out plugin); DicConsole.WriteLine($"Identified by {plugin.Name}."); Filesystem fs = (Filesystem)plugin - .GetType().GetConstructor(new[] - { - typeof(ImagePlugin), typeof(Partition), typeof(Encoding) - }).Invoke(new object[] {imageFormat, wholePart, null}); + .GetType().GetConstructor(new[] {typeof(ImagePlugin), typeof(Partition), typeof(Encoding)}) + .Invoke(new object[] {imageFormat, wholePart, null}); error = fs.Mount(options.Debug); if(error == Errno.NoError) { @@ -602,7 +629,9 @@ namespace DiscImageChef.Commands { FileEntryInfo stat = new FileEntryInfo(); - string volumeName = string.IsNullOrEmpty(fs.XmlFSType.VolumeName) ? "NO NAME" : fs.XmlFSType.VolumeName; + string volumeName = string.IsNullOrEmpty(fs.XmlFSType.VolumeName) + ? "NO NAME" + : fs.XmlFSType.VolumeName; error = fs.Stat(entry, ref stat); if(error == Errno.NoError) @@ -622,9 +651,8 @@ namespace DiscImageChef.Commands if(error != Errno.NoError) continue; Directory.CreateDirectory(Path.Combine(options.OutputDir, - fs.XmlFSType.Type, - volumeName, ".xattrs", - xattr)); + fs.XmlFSType.Type, volumeName, + ".xattrs", xattr)); outputPath = Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName, @@ -640,14 +668,20 @@ namespace DiscImageChef.Commands FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole .WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}", @@ -680,14 +714,20 @@ namespace DiscImageChef.Commands FileInfo fi = new FileInfo(outputPath); #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body try { fi.CreationTimeUtc = stat.CreationTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; } - catch { // ignored - } + catch + { + // ignored + } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body DicConsole.WriteLine("Written {0} bytes of file {1} to {2}", outBuf.Length, entry, outputPath); diff --git a/DiscImageChef/Commands/ListEncodings.cs b/DiscImageChef/Commands/ListEncodings.cs index 4b5b6c66..e5022ad9 100644 --- a/DiscImageChef/Commands/ListEncodings.cs +++ b/DiscImageChef/Commands/ListEncodings.cs @@ -39,16 +39,21 @@ namespace DiscImageChef.Commands { static class ListEncodings { - struct CommonEncodingInfo + internal static void DoList() { - public string Name; - public string DisplayName; - } - - internal static void DoList(ListEncodingsOptions encodingOptions) - { - List encodings = Encoding.GetEncodings().Select(info => new CommonEncodingInfo {Name = info.Name, DisplayName = info.GetEncoding().EncodingName}).ToList(); - encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings().Select(info => new CommonEncodingInfo {Name = info.Name, DisplayName = info.DisplayName})); + List encodings = Encoding + .GetEncodings() + .Select(info => new CommonEncodingInfo + { + Name = info.Name, + DisplayName = info.GetEncoding().EncodingName + }).ToList(); + encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings() + .Select(info => new CommonEncodingInfo + { + Name = info.Name, + DisplayName = info.DisplayName + })); DicConsole.WriteLine("{0,-16} {1,-8}", "Name", "Description"); @@ -57,5 +62,11 @@ namespace DiscImageChef.Commands Core.Statistics.AddCommand("list-encodings"); } + + struct CommonEncodingInfo + { + public string Name; + public string DisplayName; + } } } \ No newline at end of file diff --git a/DiscImageChef/Commands/Ls.cs b/DiscImageChef/Commands/Ls.cs index f7a6ef3f..9b50f8c7 100644 --- a/DiscImageChef/Commands/Ls.cs +++ b/DiscImageChef/Commands/Ls.cs @@ -150,8 +150,7 @@ namespace DiscImageChef.Commands .GetType().GetConstructor(new[] { typeof(ImagePlugin), typeof(Partition), typeof(Encoding) - }) - ?.Invoke(new object[] {imageFormat, partitions[i], null}); + })?.Invoke(new object[] {imageFormat, partitions[i], null}); if(fs == null) continue; @@ -194,8 +193,7 @@ namespace DiscImageChef.Commands if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); else - DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", - error.ToString()); + DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString()); Core.Statistics.AddFilesystem(fs.XmlFSType.Type); } @@ -225,8 +223,7 @@ namespace DiscImageChef.Commands .GetType().GetConstructor(new[] { typeof(ImagePlugin), typeof(Partition), typeof(Encoding) - }) - ?.Invoke(new object[] {imageFormat, wholePart, null}); + })?.Invoke(new object[] {imageFormat, wholePart, null}); if(fs == null) continue; error = fs.Mount(options.Debug); @@ -237,8 +234,7 @@ namespace DiscImageChef.Commands if(error == Errno.NoError) foreach(string entry in rootDir) DicConsole.WriteLine("{0}", entry); else - DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", - error.ToString()); + DicConsole.ErrorWriteLine("Error {0} reading root directory {0}", error.ToString()); Core.Statistics.AddFilesystem(fs.XmlFSType.Type); } diff --git a/DiscImageChef/Commands/MediaInfo.cs b/DiscImageChef/Commands/MediaInfo.cs index eafe87ef..c0583df0 100644 --- a/DiscImageChef/Commands/MediaInfo.cs +++ b/DiscImageChef/Commands/MediaInfo.cs @@ -62,7 +62,8 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Media-Info command", "--output-prefix={0}", options.OutputPrefix); if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; + char.IsLetter(options.DevicePath[0])) + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); @@ -194,8 +195,8 @@ namespace DiscImageChef.Commands Modes.DecodedMode? decMode = null; PeripheralDeviceTypes devType = dev.ScsiType; - sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, - 0xFF, 5, out _); + sense = dev.ModeSense10(out byte[] modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, + 0x3F, 0xFF, 5, out _); if(sense || dev.Error) sense = dev.ModeSense10(out modeBuf, out senseBuf, false, true, ScsiModeSensePageControl.Current, 0x3F, 0x00, 5, out _); @@ -227,10 +228,13 @@ namespace DiscImageChef.Commands if(decMode.Value.Header.BlockDescriptors != null && decMode.Value.Header.BlockDescriptors.Length >= 1) scsiDensityCode = (byte)decMode.Value.Header.BlockDescriptors[0].Density; - containsFloppyPage = decMode.Value.Pages.Aggregate(containsFloppyPage, (current, modePage) => current | modePage.Page == 0x05); + containsFloppyPage = + decMode.Value.Pages.Aggregate(containsFloppyPage, + (current, modePage) => current | (modePage.Page == 0x05)); } - switch(dev.ScsiType) { + switch(dev.ScsiType) + { case PeripheralDeviceTypes.DirectAccess: case PeripheralDeviceTypes.MultiMediaDevice: case PeripheralDeviceTypes.OCRWDevice: @@ -273,8 +277,8 @@ namespace DiscImageChef.Commands if(blocks != 0 && blockSize != 0) { blocks++; - DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)", blocks, - blockSize, blocks * blockSize); + DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)", + blocks, blockSize, blocks * blockSize); } break; case PeripheralDeviceTypes.SequentialAccess: @@ -289,8 +293,7 @@ namespace DiscImageChef.Commands { DataFile.WriteTo("Media-Info command", outputPrefix, "_ssc_reportdensitysupport_media.bin", "SSC REPORT DENSITY SUPPORT (MEDIA)", seqBuf); - DensitySupport.DensitySupportHeader? dens = - DensitySupport.DecodeDensity(seqBuf); + DensitySupport.DensitySupportHeader? dens = DensitySupport.DecodeDensity(seqBuf); if(dens.HasValue) { DicConsole.WriteLine("Densities supported by currently inserted media:"); @@ -309,8 +312,7 @@ namespace DiscImageChef.Commands DataFile.WriteTo("Media-Info command", outputPrefix, "_ssc_reportdensitysupport_medium_media.bin", "SSC REPORT DENSITY SUPPORT (MEDIUM & MEDIA)", seqBuf); - DensitySupport.MediaTypeSupportHeader? meds = - DensitySupport.DecodeMediumType(seqBuf); + DensitySupport.MediaTypeSupportHeader? meds = DensitySupport.DecodeMediumType(seqBuf); if(meds.HasValue) { DicConsole.WriteLine("Medium types currently inserted in device:"); @@ -443,8 +445,7 @@ namespace DiscImageChef.Commands } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.RecognizedFormatLayers, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.RecognizedFormatLayers, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Recognized Format Layers\n{0}", @@ -453,8 +454,7 @@ namespace DiscImageChef.Commands DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_formatlayers.bin", "SCSI READ DISC STRUCTURE", cmdBuf); sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.WriteProtectionStatus, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.WriteProtectionStatus, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Write Protection Status\n{0}", Sense.PrettifySense(senseBuf)); @@ -480,8 +480,7 @@ namespace DiscImageChef.Commands dskType == MediaType.HDDVDRW || dskType == MediaType.HDDVDRWDL) { sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}", Sense.PrettifySense(senseBuf)); @@ -535,7 +534,9 @@ namespace DiscImageChef.Commands dskType = MediaType.HDDVDRW; break; case DiskCategory.Nintendo: - dskType = decPfi.Value.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD; + dskType = decPfi.Value.DiscSize == DVDSize.Eighty + ? MediaType.GOD + : MediaType.WOD; break; case DiskCategory.UMD: dskType = MediaType.UMD; @@ -578,8 +579,7 @@ namespace DiscImageChef.Commands if(dskType == MediaType.DVDDownload || dskType == MediaType.DVDROM) { sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.CopyrightInformation, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: CMI\n{0}", Sense.PrettifySense(senseBuf)); @@ -587,20 +587,19 @@ namespace DiscImageChef.Commands { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_cmi.bin", "SCSI READ DISC STRUCTURE", cmdBuf); - DicConsole.WriteLine("Lead-In CMI:\n{0}", - CSS_CPRM.PrettifyLeadInCopyright(cmdBuf)); + DicConsole.WriteLine("Lead-In CMI:\n{0}", CSS_CPRM.PrettifyLeadInCopyright(cmdBuf)); } } #endregion DVD-ROM #region DVD-ROM and HD DVD-ROM - switch(dskType) { + switch(dskType) + { case MediaType.DVDDownload: case MediaType.DVDROM: case MediaType.HDDVDROM: sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.BurstCuttingArea, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: BCA\n{0}", Sense.PrettifySense(senseBuf)); @@ -630,8 +629,7 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Disc Definition Structure:\n{0}", DDS.Prettify(cmdBuf)); } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdramMediumStatus, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.DvdramMediumStatus, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Medium Status\n{0}", Sense.PrettifySense(senseBuf)); @@ -657,10 +655,10 @@ namespace DiscImageChef.Commands case MediaType.DVDR: case MediaType.HDDVDR: sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.LastBorderOutRmd, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.LastBorderOutRmd, 0, dev.Timeout, out _); if(sense) - DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Last-Out Border RMD\n{0}", + DicConsole.DebugWriteLine("Media-Info command", + "READ DISC STRUCTURE: Last-Out Border RMD\n{0}", Sense.PrettifySense(senseBuf)); else DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_lastrmd.bin", @@ -749,7 +747,8 @@ namespace DiscImageChef.Commands } #endregion DVD-R and DVD-RW - switch(dskType) { + switch(dskType) + { #region DVD-R, DVD-RW and HD DVD-R case MediaType.DVDR: case MediaType.DVDRW: @@ -774,6 +773,7 @@ namespace DiscImageChef.Commands "SCSI READ DISC STRUCTURE", cmdBuf); break; #endregion DVD-R, DVD-RW and HD DVD-R + #region All DVD+ case MediaType.DVDPR: case MediaType.DVDPRDL: @@ -798,6 +798,7 @@ namespace DiscImageChef.Commands "SCSI READ DISC STRUCTURE", cmdBuf); break; #endregion All DVD+ + #region HD DVD-ROM case MediaType.HDDVDROM: sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, @@ -817,8 +818,7 @@ namespace DiscImageChef.Commands if(dskType == MediaType.HDDVDR) { sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.HddvdrMediumStatus, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.HddvdrMediumStatus, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: HDDVD-R Medium Status\n{0}", @@ -842,8 +842,7 @@ namespace DiscImageChef.Commands dskType == MediaType.DVDPRWDL) { sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.DvdrLayerCapacity, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.DvdrLayerCapacity, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Layer Capacity\n{0}", Sense.PrettifySense(senseBuf)); @@ -853,22 +852,24 @@ namespace DiscImageChef.Commands } #endregion DVD-R DL, DVD-RW DL, DVD+R DL, DVD+RW DL - switch(dskType) { + switch(dskType) + { #region DVD-R DL case MediaType.DVDRDL: sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.MiddleZoneStart, 0, dev.Timeout, out _); if(sense) - DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Middle Zone Start\n{0}", + DicConsole.DebugWriteLine("Media-Info command", + "READ DISC STRUCTURE: Middle Zone Start\n{0}", Sense.PrettifySense(senseBuf)); else DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_mzs.bin", "SCSI READ DISC STRUCTURE", cmdBuf); sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.JumpIntervalSize, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.JumpIntervalSize, 0, dev.Timeout, out _); if(sense) - DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Jump Interval Size\n{0}", + DicConsole.DebugWriteLine("Media-Info command", + "READ DISC STRUCTURE: Jump Interval Size\n{0}", Sense.PrettifySense(senseBuf)); else DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_jis.bin", @@ -884,16 +885,18 @@ namespace DiscImageChef.Commands DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_manuallj.bin", "SCSI READ DISC STRUCTURE", cmdBuf); sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.RemapAnchorPoint, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.RemapAnchorPoint, 0, dev.Timeout, out _); if(sense) - DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Remap Anchor Point\n{0}", + DicConsole.DebugWriteLine("Media-Info command", + "READ DISC STRUCTURE: Remap Anchor Point\n{0}", Sense.PrettifySense(senseBuf)); else - DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_remapanchor.bin", - "SCSI READ DISC STRUCTURE", cmdBuf); + DataFile.WriteTo("Media-Info command", outputPrefix, + "_readdiscstructure_dvd_remapanchor.bin", "SCSI READ DISC STRUCTURE", + cmdBuf); break; #endregion DVD-R DL + #region All Blu-ray case MediaType.BDR: case MediaType.BDRE: @@ -923,13 +926,12 @@ namespace DiscImageChef.Commands #endregion All Blu-ray } - - switch(dskType) { + switch(dskType) + { #region BD-ROM only case MediaType.BDROM: sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, - MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.BdBurstCuttingArea, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: BCA\n{0}", Sense.PrettifySense(senseBuf)); @@ -941,6 +943,7 @@ namespace DiscImageChef.Commands } break; #endregion BD-ROM only + #region Writable Blu-ray only case MediaType.BDR: case MediaType.BDRE: @@ -961,7 +964,8 @@ namespace DiscImageChef.Commands sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.CartridgeStatus, 0, dev.Timeout, out _); if(sense) - DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: Cartridge Status\n{0}", + DicConsole.DebugWriteLine("Media-Info command", + "READ DISC STRUCTURE: Cartridge Status\n{0}", Sense.PrettifySense(senseBuf)); else { @@ -980,8 +984,7 @@ namespace DiscImageChef.Commands { DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_spare.bin", "SCSI READ DISC STRUCTURE", cmdBuf); - DicConsole.WriteLine("Blu-ray Spare Area Information:\n{0}", - DI.Prettify(cmdBuf)); + DicConsole.WriteLine("Blu-ray Spare Area Information:\n{0}", DI.Prettify(cmdBuf)); } sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Bd, 0, 0, MmcDiscStructureFormat.RawDfl, 0, dev.Timeout, out _); @@ -992,32 +995,30 @@ namespace DiscImageChef.Commands DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dfl.bin", "SCSI READ DISC STRUCTURE", cmdBuf); sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, - MmcDiscInformationDataTypes.TrackResources, dev.Timeout, - out _); + MmcDiscInformationDataTypes.TrackResources, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 001b\n{0}", Sense.PrettifySense(senseBuf)); else { - DicConsole.WriteLine("Track Resources Information:\n{0}", - DiscInformation.Prettify(cmdBuf)); + DicConsole.WriteLine("Track Resources Information:\n{0}", DiscInformation.Prettify(cmdBuf)); DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_001b.bin", "SCSI READ DISC INFORMATION", cmdBuf); } - sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, MmcDiscInformationDataTypes.PowResources, - dev.Timeout, out _); + sense = dev.ReadDiscInformation(out cmdBuf, out senseBuf, + MmcDiscInformationDataTypes.PowResources, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC INFORMATION 010b\n{0}", Sense.PrettifySense(senseBuf)); else { - DicConsole.WriteLine("POW Resources Information:\n{0}", - DiscInformation.Prettify(cmdBuf)); + DicConsole.WriteLine("POW Resources Information:\n{0}", DiscInformation.Prettify(cmdBuf)); DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_010b.bin", "SCSI READ DISC INFORMATION", cmdBuf); } break; #endregion Writable Blu-ray only + #region CDs case MediaType.CD: case MediaType.CDR: @@ -1028,8 +1029,7 @@ namespace DiscImageChef.Commands // We discarded all discs that falsify a TOC before requesting a real TOC // No TOC, no CD (or an empty one) - bool tocSense = - dev.ReadTocPmaAtip(out cmdBuf, out senseBuf, false, 0, 0, dev.Timeout, out _); + bool tocSense = dev.ReadTocPmaAtip(out cmdBuf, out senseBuf, false, 0, 0, dev.Timeout, out _); if(tocSense) DicConsole.DebugWriteLine("Media-Info command", "READ TOC/PMA/ATIP: TOC\n{0}", Sense.PrettifySense(senseBuf)); @@ -1073,14 +1073,14 @@ namespace DiscImageChef.Commands Sense.PrettifySense(senseBuf)); else { - DiscInformation.StandardDiscInformation? discInfo = - DiscInformation.Decode000b(cmdBuf); + DiscInformation.StandardDiscInformation? discInfo = DiscInformation.Decode000b(cmdBuf); if(discInfo.HasValue) { DicConsole.WriteLine("Standard Disc Information:\n{0}", DiscInformation.Prettify000b(discInfo)); - DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_000b.bin", - "SCSI READ DISC INFORMATION", cmdBuf); + DataFile.WriteTo("Media-Info command", outputPrefix, + "_readdiscinformation_000b.bin", "SCSI READ DISC INFORMATION", + cmdBuf); // If it is a read-only CD, check CD type if available if(dskType == MediaType.CD) @@ -1127,15 +1127,12 @@ namespace DiscImageChef.Commands foreach(TOC.CDTOCTrackDataDescriptor track in toc.Value.TrackDescriptors) { if(track.TrackNumber == 1 && - ((TocControl)(track.CONTROL & 0x0D) == - TocControl.DataTrack || - (TocControl)(track.CONTROL & 0x0D) == - TocControl.DataTrackIncremental)) allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; + ((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack || + (TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental)) + allFirstSessionTracksAreAudio &= firstTrackLastSession != 1; - if((TocControl)(track.CONTROL & 0x0D) == - TocControl.DataTrack || - (TocControl)(track.CONTROL & 0x0D) == - TocControl.DataTrackIncremental) + if((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack || + (TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrackIncremental) { hasDataTrack = true; allFirstSessionTracksAreAudio &= track.TrackNumber >= firstTrackLastSession; @@ -1168,8 +1165,8 @@ namespace DiscImageChef.Commands Sense.PrettifySense(senseBuf)); else { - DataFile.WriteTo("Media-Info command", outputPrefix, "_pma.bin", "SCSI READ TOC/PMA/ATIP", - cmdBuf); + DataFile.WriteTo("Media-Info command", outputPrefix, "_pma.bin", + "SCSI READ TOC/PMA/ATIP", cmdBuf); DicConsole.WriteLine("PMA:\n{0}", PMA.Prettify(cmdBuf)); } @@ -1182,8 +1179,7 @@ namespace DiscImageChef.Commands DataFile.WriteTo("Media-Info command", outputPrefix, "_cdtext.bin", "SCSI READ TOC/PMA/ATIP", cmdBuf); if(CDTextOnLeadIn.Decode(cmdBuf).HasValue) - DicConsole.WriteLine("CD-TEXT on Lead-In:\n{0}", - CDTextOnLeadIn.Prettify(cmdBuf)); + DicConsole.WriteLine("CD-TEXT on Lead-In:\n{0}", CDTextOnLeadIn.Prettify(cmdBuf)); } } @@ -1195,8 +1191,7 @@ namespace DiscImageChef.Commands if(dskType == MediaType.Unknown && blocks > 0) { sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, - MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, - out _); + MmcDiscStructureFormat.PhysicalInformation, 0, dev.Timeout, out _); if(sense) DicConsole.DebugWriteLine("Media-Info command", "READ DISC STRUCTURE: PFI\n{0}", Sense.PrettifySense(senseBuf)); @@ -1210,14 +1205,18 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("PFI:\n{0}", PFI.Prettify(cmdBuf)); if(nintendoPfi.Value.DiskCategory == DiskCategory.Nintendo && nintendoPfi.Value.PartVersion == 15) - switch(nintendoPfi.Value.DiscSize) { - case DVDSize.Eighty: dskType = MediaType.GOD; + switch(nintendoPfi.Value.DiscSize) + { + case DVDSize.Eighty: + dskType = MediaType.GOD; break; - case DVDSize.OneTwenty: dskType = MediaType.WOD; + case DVDSize.OneTwenty: + dskType = MediaType.WOD; break; } } } + sense = dev.ReadDiscStructure(out cmdBuf, out senseBuf, MmcDiscStructureMediaType.Dvd, 0, 0, MmcDiscStructureFormat.DiscManufacturingInformation, 0, dev.Timeout, out _); @@ -1232,7 +1231,8 @@ namespace DiscImageChef.Commands } #region Xbox - switch(dskType) { + switch(dskType) + { case MediaType.XGD: case MediaType.XGD2: case MediaType.XGD3: @@ -1305,7 +1305,8 @@ namespace DiscImageChef.Commands return; } - gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) + 1; + gameSize = (ulong)((cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3]) + + 1; DicConsole.DebugWriteLine("Dump-media command", "Game partition total size: {0} sectors", gameSize); @@ -1334,7 +1335,8 @@ namespace DiscImageChef.Commands return; } - DicConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", totalSize); + DicConsole.DebugWriteLine("Dump-media command", "Unlocked total size: {0} sectors", + totalSize); middleZone = totalSize - (PFI.Decode(cmdBuf).Value.Layer0EndPSN - PFI.Decode(cmdBuf).Value.DataAreaStartPSN + 1) - gameSize + 1; diff --git a/DiscImageChef/Commands/MediaScan.cs b/DiscImageChef/Commands/MediaScan.cs index 9a6ede31..97495a4a 100644 --- a/DiscImageChef/Commands/MediaScan.cs +++ b/DiscImageChef/Commands/MediaScan.cs @@ -48,7 +48,8 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("Media-Scan command", "--ibg-log={0}", options.IbgLogPath); if(options.DevicePath.Length == 2 && options.DevicePath[1] == ':' && options.DevicePath[0] != '/' && - char.IsLetter(options.DevicePath[0])) options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; + char.IsLetter(options.DevicePath[0])) + options.DevicePath = "\\\\.\\" + char.ToUpper(options.DevicePath[0]) + ':'; Device dev = new Device(options.DevicePath); diff --git a/DiscImageChef/Commands/PrintHex.cs b/DiscImageChef/Commands/PrintHex.cs index e2345e3b..f1edf4e8 100644 --- a/DiscImageChef/Commands/PrintHex.cs +++ b/DiscImageChef/Commands/PrintHex.cs @@ -88,7 +88,9 @@ namespace DiscImageChef.Commands } } - byte[] sector = options.LongSectors ? inputFormat.ReadSectorLong(options.StartSector + i) : inputFormat.ReadSector(options.StartSector + i); + byte[] sector = options.LongSectors + ? inputFormat.ReadSectorLong(options.StartSector + i) + : inputFormat.ReadSector(options.StartSector + i); DiscImageChef.PrintHex.PrintHexArray(sector, options.WidthBytes); } diff --git a/DiscImageChef/Commands/Statistics.cs b/DiscImageChef/Commands/Statistics.cs index 65cfe129..756c1aa1 100644 --- a/DiscImageChef/Commands/Statistics.cs +++ b/DiscImageChef/Commands/Statistics.cs @@ -104,7 +104,8 @@ namespace DiscImageChef.Commands { DicConsole.WriteLine("Benchmark statistics"); DicConsole.WriteLine("===================="); - foreach(ChecksumStats chk in Core.Statistics.AllStats.Benchmark.Checksum) DicConsole.WriteLine("Took {0} seconds to calculate {1} algorithm", chk.Value, chk.algorithm); + foreach(ChecksumStats chk in Core.Statistics.AllStats.Benchmark.Checksum) + DicConsole.WriteLine("Took {0} seconds to calculate {1} algorithm", chk.Value, chk.algorithm); DicConsole.WriteLine("Took {0} seconds to calculate all algorithms sequentially", Core.Statistics.AllStats.Benchmark.Sequential); @@ -182,8 +183,8 @@ namespace DiscImageChef.Commands DicConsole.WriteLine("Media statistics"); DicConsole.WriteLine("================"); foreach(MediaStats ms in Core.Statistics.AllStats.Medias) - DicConsole.WriteLine("Media type {0} has been found {1} times in a {2} image.", ms.type, - ms.Value, ms.real ? "real" : "media"); + DicConsole.WriteLine("Media type {0} has been found {1} times in a {2} image.", ms.type, ms.Value, + ms.real ? "real" : "media"); DicConsole.WriteLine(); thereAreStats = true; diff --git a/DiscImageChef/Commands/Verify.cs b/DiscImageChef/Commands/Verify.cs index c68f137b..61eb47e6 100644 --- a/DiscImageChef/Commands/Verify.cs +++ b/DiscImageChef/Commands/Verify.cs @@ -241,14 +241,12 @@ namespace DiscImageChef.Commands DicConsole.VerboseWriteLine("LBAs with error:"); if(failingLbas.Count == (int)inputFormat.GetSectors()) DicConsole.VerboseWriteLine("\tall sectors."); - else - foreach(ulong t in failingLbas) DicConsole.VerboseWriteLine("\t{0}", t); + else foreach(ulong t in failingLbas) DicConsole.VerboseWriteLine("\t{0}", t); DicConsole.WriteLine("LBAs without checksum:"); if(unknownLbas.Count == (int)inputFormat.GetSectors()) DicConsole.VerboseWriteLine("\tall sectors."); - else - foreach(ulong t in unknownLbas) DicConsole.VerboseWriteLine("\t{0}", t); + else foreach(ulong t in unknownLbas) DicConsole.VerboseWriteLine("\t{0}", t); } DicConsole.WriteLine("Total sectors........... {0}", inputFormat.GetSectors()); diff --git a/DiscImageChef/Main.cs b/DiscImageChef/Main.cs index d5678b7f..9f6fbdad 100644 --- a/DiscImageChef/Main.cs +++ b/DiscImageChef/Main.cs @@ -51,130 +51,136 @@ namespace DiscImageChef Statistics.LoadStats(); if(Settings.Settings.Current.Stats.ShareStats) Statistics.SubmitStats(); - Parser.Default - .ParseArguments(args, typeof(AnalyzeOptions), typeof(CompareOptions), typeof(ChecksumOptions), typeof(EntropyOptions), typeof(VerifyOptions), typeof(PrintHexOptions), typeof(DecodeOptions), typeof(DeviceInfoOptions), typeof(MediaInfoOptions), typeof(MediaScanOptions), typeof(FormatsOptions), typeof(BenchmarkOptions), typeof(CreateSidecarOptions), typeof(DumpMediaOptions), typeof(DeviceReportOptions), typeof(ConfigureOptions), typeof(StatsOptions), typeof(LsOptions), typeof(ExtractFilesOptions), typeof(ListDevicesOptions), typeof(ListEncodingsOptions)).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Analyze.DoAnalyze(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Compare.DoCompare(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Checksum.DoChecksum(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Entropy.DoEntropy(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Verify.DoVerify(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Commands.PrintHex.DoPrintHex(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Decode.DoDecode(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - DeviceInfo.DoDeviceInfo(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - MediaInfo.DoMediaInfo(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - MediaScan.DoMediaScan(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Formats.ListFormats(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Benchmark.DoBenchmark(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - CreateSidecar.DoSidecar(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - DumpMedia.DoDumpMedia(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - DeviceReport.DoDeviceReport(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - Ls.DoLs(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - ExtractFiles.DoExtractFiles(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - ListDevices.DoListDevices(opts); - }).WithParsed(opts => - { - if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; - if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; - PrintCopyright(); - ListEncodings.DoList(opts); - }).WithParsed(opts => - { - PrintCopyright(); - Configure.DoConfigure(); - }).WithParsed(opts => - { - PrintCopyright(); - Commands.Statistics.ShowStats(); - }).WithNotParsed(errs => Environment.Exit(1)); + Parser.Default.ParseArguments(args, typeof(AnalyzeOptions), typeof(CompareOptions), typeof(ChecksumOptions), + typeof(EntropyOptions), typeof(VerifyOptions), typeof(PrintHexOptions), + typeof(DecodeOptions), typeof(DeviceInfoOptions), typeof(MediaInfoOptions), + typeof(MediaScanOptions), typeof(FormatsOptions), typeof(BenchmarkOptions), + typeof(CreateSidecarOptions), typeof(DumpMediaOptions), + typeof(DeviceReportOptions), typeof(ConfigureOptions), typeof(StatsOptions), + typeof(LsOptions), typeof(ExtractFilesOptions), typeof(ListDevicesOptions), + typeof(ListEncodingsOptions)).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Analyze.DoAnalyze(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Compare.DoCompare(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Checksum.DoChecksum(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Entropy.DoEntropy(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Verify.DoVerify(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Commands.PrintHex.DoPrintHex(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Decode.DoDecode(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + DeviceInfo.DoDeviceInfo(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + MediaInfo.DoMediaInfo(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + MediaScan.DoMediaScan(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Formats.ListFormats(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Benchmark.DoBenchmark(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + CreateSidecar.DoSidecar(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + DumpMedia.DoDumpMedia(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + DeviceReport.DoDeviceReport(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + Ls.DoLs(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + ExtractFiles.DoExtractFiles(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + ListDevices.DoListDevices(opts); + }).WithParsed(opts => + { + if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; + if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; + PrintCopyright(); + ListEncodings.DoList(); + }).WithParsed(opts => + { + PrintCopyright(); + Configure.DoConfigure(); + }).WithParsed(opts => + { + PrintCopyright(); + Commands.Statistics.ShowStats(); + }).WithNotParsed(errs => Environment.Exit(1)); Statistics.SaveStats(); } diff --git a/DiscImageChef/Progress.cs b/DiscImageChef/Progress.cs index df08727e..a92ed063 100644 --- a/DiscImageChef/Progress.cs +++ b/DiscImageChef/Progress.cs @@ -68,7 +68,7 @@ namespace DiscImageChef } internal static void UpdateTwoProgress(string text, long current, long maximum, string text2, long current2, - long maximum2) + long maximum2) { DicConsole.Write("\r" + text + ": " + text2); }