mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Invert 'if' statement to reduce nesting.
This commit is contained in:
@@ -162,33 +162,32 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.WriteLine("Partition description:");
|
||||
DicConsole.WriteLine(partitions[i].Description);
|
||||
|
||||
if(options.SearchForFilesystems)
|
||||
if(!options.SearchForFilesystems) continue;
|
||||
|
||||
DicConsole.WriteLine("Identifying filesystem on partition");
|
||||
|
||||
Core.Filesystems.Identify(imageFormat, out idPlugins, partitions[i]);
|
||||
if(idPlugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
|
||||
else if(idPlugins.Count > 1)
|
||||
{
|
||||
DicConsole.WriteLine("Identifying filesystem on partition");
|
||||
DicConsole.WriteLine(string.Format("Identified by {0} plugins", idPlugins.Count));
|
||||
|
||||
Core.Filesystems.Identify(imageFormat, out idPlugins, partitions[i]);
|
||||
if(idPlugins.Count == 0) DicConsole.WriteLine("Filesystem not identified");
|
||||
else if(idPlugins.Count > 1)
|
||||
{
|
||||
DicConsole.WriteLine(string.Format("Identified by {0} plugins", idPlugins.Count));
|
||||
|
||||
foreach(string pluginName in idPlugins)
|
||||
if(plugins.PluginsList.TryGetValue(pluginName, out plugin))
|
||||
{
|
||||
DicConsole.WriteLine(string.Format("As identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, partitions[i], out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugins.PluginsList.TryGetValue(idPlugins[0], out plugin);
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, partitions[i], out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
}
|
||||
foreach(string pluginName in idPlugins)
|
||||
if(plugins.PluginsList.TryGetValue(pluginName, out plugin))
|
||||
{
|
||||
DicConsole.WriteLine(string.Format("As identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, partitions[i], out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugins.PluginsList.TryGetValue(idPlugins[0], out plugin);
|
||||
DicConsole.WriteLine(string.Format("Identified by {0}.", plugin.Name));
|
||||
plugin.GetInformation(imageFormat, partitions[i], out information);
|
||||
DicConsole.Write(information);
|
||||
Core.Statistics.AddFilesystem(plugin.XmlFSType.Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,164 +289,150 @@ namespace DiscImageChef.Commands
|
||||
if(page >= 0x01 && page <= 0x7F)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("ASCII Page {0:X2}h: {1}", page,
|
||||
Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf));
|
||||
if(sense) continue;
|
||||
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
DicConsole.WriteLine("ASCII Page {0:X2}h: {1}", page,
|
||||
Decoders.SCSI.EVPD.DecodeASCIIPage(inqBuf));
|
||||
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x80)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("Unit Serial Number: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePage80(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("Unit Serial Number: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePage80(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x81)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_81(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_81(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x82)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("ASCII implemented operating definitions: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePage82(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("ASCII implemented operating definitions: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePage82(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x83)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_83(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_83(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x84)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_84(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_84(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x85)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_85(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_85(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x86)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_86(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_86(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0x89)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_89(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_89(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xB0)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_B0(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_B0(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xB1)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("Manufacturer-assigned Serial Number: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePageB1(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("Manufacturer-assigned Serial Number: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePageB1(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xB2)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("TapeAlert Supported Flags Bitmap: 0x{0:X16}",
|
||||
Decoders.SCSI.EVPD.DecodePageB2(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("TapeAlert Supported Flags Bitmap: 0x{0:X16}",
|
||||
Decoders.SCSI.EVPD.DecodePageB2(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xB3)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("Automation Device Serial Number: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePageB3(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("Automation Device Serial Number: {0}",
|
||||
Decoders.SCSI.EVPD.DecodePageB3(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xB4)
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("Data Transfer Device Element Address: 0x{0}",
|
||||
Decoders.SCSI.EVPD.DecodePageB4(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("Data Transfer Device Element Address: 0x{0}",
|
||||
Decoders.SCSI.EVPD.DecodePageB4(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xC0 &&
|
||||
StringHandlers
|
||||
@@ -454,13 +440,12 @@ namespace DiscImageChef.Commands
|
||||
"quantum")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C0_Quantum(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C0_Quantum(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xC0 &&
|
||||
StringHandlers
|
||||
@@ -468,13 +453,12 @@ namespace DiscImageChef.Commands
|
||||
"seagate")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C0_Seagate(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C0_Seagate(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xC0 &&
|
||||
StringHandlers
|
||||
@@ -482,13 +466,12 @@ namespace DiscImageChef.Commands
|
||||
"ibm")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C0_IBM(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C0_IBM(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xC1 &&
|
||||
StringHandlers
|
||||
@@ -496,13 +479,12 @@ namespace DiscImageChef.Commands
|
||||
"ibm")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C1_IBM(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}", Decoders.SCSI.EVPD.PrettifyPage_C1_IBM(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if((page == 0xC0 || page == 0xC1) &&
|
||||
StringHandlers
|
||||
@@ -510,14 +492,13 @@ namespace DiscImageChef.Commands
|
||||
"certance")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders.SCSI.EVPD.PrettifyPage_C0_C1_Certance(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders.SCSI.EVPD.PrettifyPage_C0_C1_Certance(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(
|
||||
(page == 0xC2 || page == 0xC3 || page == 0xC4 || page == 0xC5 || page == 0xC6) &&
|
||||
@@ -525,16 +506,15 @@ namespace DiscImageChef.Commands
|
||||
.Trim() == "certance")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders
|
||||
.SCSI.EVPD
|
||||
.PrettifyPage_C2_C3_C4_C5_C6_Certance(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders
|
||||
.SCSI.EVPD
|
||||
.PrettifyPage_C2_C3_C4_C5_C6_Certance(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if((page == 0xC0 || page == 0xC1 || page == 0xC2 || page == 0xC3 || page == 0xC4 ||
|
||||
page == 0xC5) &&
|
||||
@@ -543,14 +523,13 @@ namespace DiscImageChef.Commands
|
||||
"hp")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders.SCSI.EVPD.PrettifyPage_C0_to_C5_HP(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders.SCSI.EVPD.PrettifyPage_C0_to_C5_HP(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else if(page == 0xDF &&
|
||||
StringHandlers
|
||||
@@ -558,28 +537,26 @@ namespace DiscImageChef.Commands
|
||||
"certance")
|
||||
{
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
{
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders.SCSI.EVPD.PrettifyPage_DF_Certance(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
if(sense) continue;
|
||||
|
||||
DicConsole.WriteLine("{0}",
|
||||
Decoders.SCSI.EVPD.PrettifyPage_DF_Certance(inqBuf));
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(page != 0x00)
|
||||
{
|
||||
DicConsole.DebugWriteLine("Device-Info command",
|
||||
"Found undecoded SCSI VPD page 0x{0:X2}", page);
|
||||
if(page == 0x00) continue;
|
||||
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
DicConsole.DebugWriteLine("Device-Info command",
|
||||
"Found undecoded SCSI VPD page 0x{0:X2}", page);
|
||||
|
||||
sense = dev.ScsiInquiry(out inqBuf, out senseBuf, page);
|
||||
if(!sense)
|
||||
DataFile.WriteTo("Device-Info command", options.OutputPrefix,
|
||||
string.Format("_scsi_evpd_{0:X2}h.bin", page),
|
||||
string.Format("SCSI INQUIRY EVPD {0:X2}h", page), inqBuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace DiscImageChef.Commands
|
||||
Core.Statistics.AddMediaFormat(inputFormat.GetImageFormat());
|
||||
Core.Statistics.AddMedia(inputFormat.ImageInfo.MediaType, false);
|
||||
Core.Statistics.AddFilter(inputFilter.Name);
|
||||
double entropy = 0;
|
||||
ulong[] entTable;
|
||||
ulong sectors;
|
||||
|
||||
if(options.SeparatedTracks)
|
||||
try
|
||||
@@ -81,11 +84,11 @@ namespace DiscImageChef.Commands
|
||||
foreach(Track currentTrack in inputTracks)
|
||||
{
|
||||
Sha1Context sha1CtxTrack = new Sha1Context();
|
||||
ulong[] entTable = new ulong[256];
|
||||
entTable = new ulong[256];
|
||||
ulong trackSize = 0;
|
||||
List<string> uniqueSectorsPerTrack = new List<string>();
|
||||
|
||||
ulong sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
|
||||
sectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector + 1;
|
||||
DicConsole.WriteLine("Track {0} has {1} sectors", currentTrack.TrackSequence, sectors);
|
||||
|
||||
for(ulong i = currentTrack.TrackStartSector; i <= currentTrack.TrackEndSector; i++)
|
||||
@@ -105,7 +108,6 @@ namespace DiscImageChef.Commands
|
||||
trackSize += (ulong)sector.LongLength;
|
||||
}
|
||||
|
||||
double entropy = 0;
|
||||
foreach(ulong l in entTable)
|
||||
{
|
||||
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
@@ -132,56 +134,54 @@ namespace DiscImageChef.Commands
|
||||
else DicConsole.ErrorWriteLine("Unable to get separate tracks, not calculating their entropy");
|
||||
}
|
||||
|
||||
if(options.WholeDisc)
|
||||
if(!options.WholeDisc) return;
|
||||
|
||||
Sha1Context sha1Ctx = new Sha1Context();
|
||||
entTable = new ulong[256];
|
||||
ulong diskSize = 0;
|
||||
List<string> uniqueSectors = new List<string>();
|
||||
|
||||
sectors = inputFormat.GetSectors();
|
||||
DicConsole.WriteLine("Sectors {0}", sectors);
|
||||
|
||||
sha1Ctx.Init();
|
||||
|
||||
for(ulong i = 0; i < sectors; i++)
|
||||
{
|
||||
Sha1Context sha1Ctx = new Sha1Context();
|
||||
ulong[] entTable = new ulong[256];
|
||||
ulong diskSize = 0;
|
||||
List<string> uniqueSectors = new List<string>();
|
||||
|
||||
ulong sectors = inputFormat.GetSectors();
|
||||
DicConsole.WriteLine("Sectors {0}", sectors);
|
||||
|
||||
sha1Ctx.Init();
|
||||
|
||||
for(ulong i = 0; i < sectors; i++)
|
||||
{
|
||||
DicConsole.Write("\rEntropying sector {0}", i + 1);
|
||||
byte[] sector = inputFormat.ReadSector(i);
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
{
|
||||
byte[] garbage;
|
||||
string sectorHash = sha1Ctx.Data(sector, out garbage);
|
||||
if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash);
|
||||
}
|
||||
|
||||
foreach(byte b in sector) entTable[b]++;
|
||||
|
||||
diskSize += (ulong)sector.LongLength;
|
||||
}
|
||||
|
||||
double entropy = 0;
|
||||
foreach(ulong l in entTable)
|
||||
{
|
||||
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
double frequency = (double)l / (double)diskSize;
|
||||
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
entropy += -(frequency * Math.Log(frequency, 2));
|
||||
}
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
DicConsole.WriteLine("Entropy for disk is {0:F4}.", entropy);
|
||||
DicConsole.Write("\rEntropying sector {0}", i + 1);
|
||||
byte[] sector = inputFormat.ReadSector(i);
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
{
|
||||
byte[] garbage;
|
||||
string sectorHash = sha1Ctx.Data(sector, out garbage);
|
||||
if(!uniqueSectors.Contains(sectorHash)) uniqueSectors.Add(sectorHash);
|
||||
}
|
||||
|
||||
foreach(byte b in sector) entTable[b]++;
|
||||
|
||||
diskSize += (ulong)sector.LongLength;
|
||||
}
|
||||
|
||||
foreach(ulong l in entTable)
|
||||
{
|
||||
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
DicConsole.WriteLine("Disk has {0} unique sectors ({1:P3})", uniqueSectors.Count,
|
||||
(double)uniqueSectors.Count / (double)sectors);
|
||||
double frequency = (double)l / (double)diskSize;
|
||||
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
entropy += -(frequency * Math.Log(frequency, 2));
|
||||
}
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
DicConsole.WriteLine("Entropy for disk is {0:F4}.", entropy);
|
||||
|
||||
if(options.DuplicatedSectors)
|
||||
#pragma warning disable IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
DicConsole.WriteLine("Disk has {0} unique sectors ({1:P3})", uniqueSectors.Count,
|
||||
(double)uniqueSectors.Count / (double)sectors);
|
||||
#pragma warning restore IDE0004 // Cast is necessary, otherwise incorrect value is created
|
||||
|
||||
Core.Statistics.AddCommand("entropy");
|
||||
}
|
||||
Core.Statistics.AddCommand("entropy");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -198,57 +198,56 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError)
|
||||
if(error != Errno.NoError) continue;
|
||||
|
||||
Directory
|
||||
.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName,
|
||||
".xattrs",
|
||||
xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type, volumeName,
|
||||
".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
Directory
|
||||
.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName,
|
||||
".xattrs",
|
||||
xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type, volumeName,
|
||||
".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
outputFile =
|
||||
new FileStream(outputPath,
|
||||
FileMode.CreateNew,
|
||||
FileAccess.ReadWrite,
|
||||
FileShare.None);
|
||||
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
|
||||
outputFile.Close();
|
||||
FileInfo fi = new FileInfo(outputPath);
|
||||
outputFile =
|
||||
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
|
||||
{
|
||||
fi.CreationTimeUtc = stat.CreationTimeUtc;
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
|
||||
}
|
||||
catch { }
|
||||
#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);
|
||||
try
|
||||
{
|
||||
fi.CreationTimeUtc = stat.CreationTimeUtc;
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
fi.LastWriteTimeUtc = stat.LastWriteTimeUtc;
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
fi.LastAccessTimeUtc = stat.AccessTimeUtc;
|
||||
}
|
||||
catch { }
|
||||
#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);
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,44 +344,43 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError)
|
||||
if(error != Errno.NoError) continue;
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName,
|
||||
".xattrs", xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir, fs.XmlFSType.Type,
|
||||
volumeName, ".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName,
|
||||
".xattrs", xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir, fs.XmlFSType.Type,
|
||||
volumeName, ".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
outputFile =
|
||||
new FileStream(outputPath, FileMode.CreateNew,
|
||||
FileAccess.ReadWrite,
|
||||
FileShare.None);
|
||||
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
|
||||
outputFile.Close();
|
||||
FileInfo fi = new FileInfo(outputPath);
|
||||
outputFile =
|
||||
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 { fi.CreationTimeUtc = stat.CreationTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
|
||||
catch { }
|
||||
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
|
||||
catch { }
|
||||
#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);
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
DicConsole
|
||||
.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
|
||||
xattrBuf.Length, xattr, entry,
|
||||
outputPath);
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,44 +486,43 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError)
|
||||
if(error != Errno.NoError) continue;
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName,
|
||||
".xattrs", xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir, fs.XmlFSType.Type,
|
||||
volumeName, ".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName,
|
||||
".xattrs", xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir, fs.XmlFSType.Type,
|
||||
volumeName, ".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
outputFile =
|
||||
new FileStream(outputPath, FileMode.CreateNew,
|
||||
FileAccess.ReadWrite,
|
||||
FileShare.None);
|
||||
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
|
||||
outputFile.Close();
|
||||
FileInfo fi = new FileInfo(outputPath);
|
||||
outputFile =
|
||||
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 { fi.CreationTimeUtc = stat.CreationTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
|
||||
catch { }
|
||||
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
|
||||
catch { }
|
||||
#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);
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
DicConsole
|
||||
.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
|
||||
xattrBuf.Length, xattr, entry,
|
||||
outputPath);
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,42 +613,41 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError)
|
||||
if(error != Errno.NoError) continue;
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName, ".xattrs",
|
||||
xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName,
|
||||
".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(options.OutputDir,
|
||||
fs.XmlFSType.Type,
|
||||
volumeName, ".xattrs",
|
||||
xattr));
|
||||
|
||||
outputPath =
|
||||
Path.Combine(options.OutputDir, fs.XmlFSType.Type, volumeName,
|
||||
".xattrs", xattr, entry);
|
||||
|
||||
if(!File.Exists(outputPath))
|
||||
{
|
||||
outputFile =
|
||||
new FileStream(outputPath, FileMode.CreateNew,
|
||||
FileAccess.ReadWrite, FileShare.None);
|
||||
outputFile.Write(xattrBuf, 0, xattrBuf.Length);
|
||||
outputFile.Close();
|
||||
FileInfo fi = new FileInfo(outputPath);
|
||||
outputFile =
|
||||
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 { fi.CreationTimeUtc = stat.CreationTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
|
||||
catch { }
|
||||
try { fi.CreationTimeUtc = stat.CreationTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastWriteTimeUtc = stat.LastWriteTimeUtc; }
|
||||
catch { }
|
||||
try { fi.LastAccessTimeUtc = stat.AccessTimeUtc; }
|
||||
catch { }
|
||||
#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);
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
DicConsole
|
||||
.WriteLine("Written {0} bytes of xattr {1} from file {2} to {3}",
|
||||
xattrBuf.Length, xattr, entry, outputPath);
|
||||
}
|
||||
else
|
||||
DicConsole
|
||||
.ErrorWriteLine("Cannot write xattr {0} for {1}, output exists",
|
||||
xattr, entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -261,13 +261,14 @@ namespace DiscImageChef.Commands
|
||||
stat.Inode, stat.Length, entry);
|
||||
|
||||
error = fs.ListXAttr(entry, ref xattrs);
|
||||
if(error == Errno.NoError)
|
||||
foreach(string xattr in xattrs)
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError) DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length);
|
||||
}
|
||||
if(error != Errno.NoError) continue;
|
||||
|
||||
foreach(string xattr in xattrs)
|
||||
{
|
||||
byte[] xattrBuf = new byte[0];
|
||||
error = fs.GetXattr(entry, xattr, ref xattrBuf);
|
||||
if(error == Errno.NoError) DicConsole.WriteLine("\t\t{0}\t{1} bytes", xattr, xattrBuf.Length);
|
||||
}
|
||||
}
|
||||
else DicConsole.WriteLine("{0}", entry);
|
||||
}
|
||||
|
||||
@@ -1369,13 +1369,12 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
DataFile.WriteTo("Media-Info command", outputPrefix, "_mediaserialnumber.bin",
|
||||
"SCSI READ MEDIA SERIAL NUMBER", cmdBuf);
|
||||
if(cmdBuf.Length >= 4)
|
||||
{
|
||||
DicConsole.Write("Media Serial Number: ");
|
||||
for(int i = 4; i < cmdBuf.Length; i++) DicConsole.Write("{0:X2}", cmdBuf[i]);
|
||||
if(cmdBuf.Length < 4) return;
|
||||
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
DicConsole.Write("Media Serial Number: ");
|
||||
for(int i = 4; i < cmdBuf.Length; i++) DicConsole.Write("{0:X2}", cmdBuf[i]);
|
||||
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user