REFACTOR: Final cleanup of DiscImageChef.Core.

This commit is contained in:
2017-12-23 17:41:23 +00:00
parent e05de44620
commit 380dbad1a0
48 changed files with 986 additions and 1017 deletions

View File

@@ -40,14 +40,14 @@ using PlatformID = DiscImageChef.Interop.PlatformID;
namespace DiscImageChef.Core.Logging
{
/// <summary>
/// Creates a dump log
/// Creates a dump log
/// </summary>
public class DumpLog
{
readonly StreamWriter logSw;
/// <summary>
/// Initializes the dump log
/// Initializes the dump log
/// </summary>
/// <param name="outputFile">Output log file</param>
/// <param name="dev">Device</param>
@@ -122,7 +122,7 @@ namespace DiscImageChef.Core.Logging
}
/// <summary>
/// Adds a new line to the dump log
/// Adds a new line to the dump log
/// </summary>
/// <param name="format">Format string</param>
/// <param name="args">Arguments</param>
@@ -136,7 +136,7 @@ namespace DiscImageChef.Core.Logging
}
/// <summary>
/// Finishes and closes the dump log
/// Finishes and closes the dump log
/// </summary>
public void Close()
{

View File

@@ -39,26 +39,26 @@ using DiscImageChef.Devices;
namespace DiscImageChef.Core.Logging
{
/// <summary>
/// Implements a log in the format used by IMGBurn
/// Implements a log in the format used by IMGBurn
/// </summary>
class IbgLog
{
StringBuilder ibgSb;
DateTime ibgDatePoint;
CultureInfo ibgCulture;
double ibgStartSpeed;
string ibgMediaType;
DateTime ibgDatePoint;
double ibgDivider;
bool ibgStartSet;
double ibgMaxSpeed;
double ibgIntSpeed;
int ibgSnaps;
ulong ibgIntSector;
double ibgIntSpeed;
double ibgMaxSpeed;
string ibgMediaType;
int ibgSampleRate;
StringBuilder ibgSb;
int ibgSnaps;
bool ibgStartSet;
double ibgStartSpeed;
string logFile;
/// <summary>
/// Initializes the IMGBurn log
/// Initializes the IMGBurn log
/// </summary>
/// <param name="outputFile">Log file</param>
/// <param name="currentProfile">Profile as defined by SCSI MultiMedia Commands specification</param>
@@ -201,7 +201,7 @@ namespace DiscImageChef.Core.Logging
}
/// <summary>
/// Adds a new speed snapshot to the log
/// Adds a new speed snapshot to the log
/// </summary>
/// <param name="sector">Sector for the snapshot</param>
/// <param name="currentSpeed">Current speed at the snapshot</param>
@@ -221,8 +221,8 @@ namespace DiscImageChef.Core.Logging
ibgStartSet = true;
}
ibgSb.AppendFormat("{0:0.00},{1},{2:0},0", ibgIntSpeed / ibgSnaps / ibgDivider, ibgIntSector,
ibgSampleRate).AppendLine();
ibgSb.AppendFormat("{0:0.00},{1},{2:0},0", ibgIntSpeed / ibgSnaps / ibgDivider, ibgIntSector, ibgSampleRate)
.AppendLine();
if(ibgIntSpeed / ibgSnaps / ibgDivider > ibgMaxSpeed) ibgMaxSpeed = ibgIntSpeed / ibgDivider;
ibgDatePoint = DateTime.Now;
@@ -233,7 +233,7 @@ namespace DiscImageChef.Core.Logging
}
/// <summary>
/// Closes the IMGBurn log
/// Closes the IMGBurn log
/// </summary>
/// <param name="dev">Device</param>
/// <param name="blocks">Media blocks</param>
@@ -243,9 +243,10 @@ namespace DiscImageChef.Core.Logging
/// <param name="averageSpeed">Average speed</param>
/// <param name="devicePath">Device path</param>
internal void Close(Device dev, ulong blocks, ulong blockSize, double totalSeconds, double currentSpeed,
double averageSpeed, string devicePath)
double averageSpeed, string devicePath)
{
if(logFile == null) return;
FileStream ibgFs = new FileStream(logFile, FileMode.Create);
StringBuilder ibgHeader = new StringBuilder();
string ibgBusType;
@@ -288,8 +289,7 @@ namespace DiscImageChef.Core.Logging
ibgHeader.AppendLine();
ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_START={0:0.00}", ibgStartSpeed).AppendLine();
ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_END={0:0.00}", currentSpeed / ibgDivider).AppendLine();
ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / ibgDivider)
.AppendLine();
ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_AVERAGE={0:0.00}", averageSpeed / ibgDivider).AppendLine();
ibgHeader.AppendFormat(ibgCulture, "VERIFY_SPEED_MAX={0:0.00}", ibgMaxSpeed).AppendLine();
ibgHeader.AppendFormat(ibgCulture, "VERIFY_TIME_TAKEN={0:0}", Math.Floor(totalSeconds)).AppendLine();
ibgHeader.AppendLine("[END_CONFIGURATION]");

View File

@@ -39,15 +39,15 @@ using DiscImageChef.Devices;
namespace DiscImageChef.Core.Logging
{
/// <summary>
/// Implements a log in the format used by MHDD
/// Implements a log in the format used by MHDD
/// </summary>
class MhddLog
{
MemoryStream mhddFs;
string logFile;
MemoryStream mhddFs;
/// <summary>
/// Initializes the MHDD log
/// Initializes the MHDD log
/// </summary>
/// <param name="outputFile">Log file</param>
/// <param name="dev">Device</param>
@@ -60,7 +60,7 @@ namespace DiscImageChef.Core.Logging
mhddFs = new MemoryStream();
logFile = outputFile;
string mode;
switch(dev.Type)
@@ -90,10 +90,9 @@ namespace DiscImageChef.Core.Logging
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);
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);
@@ -135,7 +134,7 @@ namespace DiscImageChef.Core.Logging
}
/// <summary>
/// Logs a new read
/// Logs a new read
/// </summary>
/// <param name="sector">Starting sector</param>
/// <param name="duration">Duration in milliseconds</param>
@@ -151,7 +150,7 @@ namespace DiscImageChef.Core.Logging
}
/// <summary>
/// Closes and writes to file the MHDD log
/// Closes and writes to file the MHDD log
/// </summary>
internal void Close()
{