mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Code cleanup.
This commit is contained in:
@@ -43,7 +43,7 @@ namespace DiscImageChef.Core.Logging
|
||||
/// </summary>
|
||||
class MhddLog
|
||||
{
|
||||
string logFile;
|
||||
string logFile;
|
||||
MemoryStream mhddFs;
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +58,7 @@ namespace DiscImageChef.Core.Logging
|
||||
{
|
||||
if(dev == null || string.IsNullOrEmpty(outputFile)) return;
|
||||
|
||||
mhddFs = new MemoryStream();
|
||||
mhddFs = new MemoryStream();
|
||||
logFile = outputFile;
|
||||
|
||||
string mode;
|
||||
@@ -86,51 +86,52 @@ namespace DiscImageChef.Core.Logging
|
||||
break;
|
||||
}
|
||||
|
||||
string device = $"DEVICE: {dev.Manufacturer} {dev.Model}";
|
||||
string fw = $"F/W: {dev.Revision}";
|
||||
string sn = $"S/N: {dev.Serial}";
|
||||
string sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks);
|
||||
string device = $"DEVICE: {dev.Manufacturer} {dev.Model}";
|
||||
string fw = $"F/W: {dev.Revision}";
|
||||
string sn = $"S/N: {dev.Serial}";
|
||||
string sectors = string.Format(new CultureInfo("en-US"), "SECTORS: {0:n0}", blocks);
|
||||
string sectorsize = string.Format(new CultureInfo("en-US"), "SECTOR SIZE: {0:n0} bytes", blockSize);
|
||||
string scanblocksize =
|
||||
string.Format(new CultureInfo("en-US"), "SCAN BLOCK SIZE: {0:n0} sectors", blocksToRead);
|
||||
const string MHDD_VER = "VER:2 ";
|
||||
|
||||
byte[] deviceBytes = Encoding.ASCII.GetBytes(device);
|
||||
byte[] modeBytes = Encoding.ASCII.GetBytes(mode);
|
||||
byte[] fwBytes = Encoding.ASCII.GetBytes(fw);
|
||||
byte[] snBytes = Encoding.ASCII.GetBytes(sn);
|
||||
byte[] sectorsBytes = Encoding.ASCII.GetBytes(sectors);
|
||||
byte[] sectorsizeBytes = Encoding.ASCII.GetBytes(sectorsize);
|
||||
byte[] deviceBytes = Encoding.ASCII.GetBytes(device);
|
||||
byte[] modeBytes = Encoding.ASCII.GetBytes(mode);
|
||||
byte[] fwBytes = Encoding.ASCII.GetBytes(fw);
|
||||
byte[] snBytes = Encoding.ASCII.GetBytes(sn);
|
||||
byte[] sectorsBytes = Encoding.ASCII.GetBytes(sectors);
|
||||
byte[] sectorsizeBytes = Encoding.ASCII.GetBytes(sectorsize);
|
||||
byte[] scanblocksizeBytes = Encoding.ASCII.GetBytes(scanblocksize);
|
||||
byte[] verBytes = Encoding.ASCII.GetBytes(MHDD_VER);
|
||||
byte[] verBytes = Encoding.ASCII.GetBytes(MHDD_VER);
|
||||
|
||||
uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length + snBytes.Length +
|
||||
uint pointer = (uint)(deviceBytes.Length + modeBytes.Length + fwBytes.Length +
|
||||
snBytes.Length +
|
||||
sectorsBytes.Length + sectorsizeBytes.Length + scanblocksizeBytes.Length +
|
||||
verBytes.Length + 2 * 9 + // New lines
|
||||
4); // Pointer
|
||||
verBytes.Length + 2 * 9 + // New lines
|
||||
4); // Pointer
|
||||
|
||||
byte[] newLine = new byte[2];
|
||||
newLine[0] = 0x0D;
|
||||
newLine[1] = 0x0A;
|
||||
|
||||
mhddFs.Write(BitConverter.GetBytes(pointer), 0, 4);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(verBytes, 0, verBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(modeBytes, 0, modeBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(deviceBytes, 0, deviceBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(fwBytes, 0, fwBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(snBytes, 0, snBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(sectorsBytes, 0, sectorsBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(sectorsizeBytes, 0, sectorsizeBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(scanblocksizeBytes, 0, scanblocksizeBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(verBytes, 0, verBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(modeBytes, 0, modeBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(deviceBytes, 0, deviceBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(fwBytes, 0, fwBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(snBytes, 0, snBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(sectorsBytes, 0, sectorsBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(sectorsizeBytes, 0, sectorsizeBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
mhddFs.Write(scanblocksizeBytes, 0, scanblocksizeBytes.Length);
|
||||
mhddFs.Write(newLine, 0, 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,10 +143,10 @@ namespace DiscImageChef.Core.Logging
|
||||
{
|
||||
if(logFile == null) return;
|
||||
|
||||
byte[] sectorBytes = BitConverter.GetBytes(sector);
|
||||
byte[] sectorBytes = BitConverter.GetBytes(sector);
|
||||
byte[] durationBytes = BitConverter.GetBytes((ulong)(duration * 1000));
|
||||
|
||||
mhddFs.Write(sectorBytes, 0, 8);
|
||||
mhddFs.Write(sectorBytes, 0, 8);
|
||||
mhddFs.Write(durationBytes, 0, 8);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user