diff --git a/DiscImageChef.Core/Logging/IBGLog.cs b/DiscImageChef.Core/Logging/IBGLog.cs index 01bc6b903..7cc8ab02c 100644 --- a/DiscImageChef.Core/Logging/IBGLog.cs +++ b/DiscImageChef.Core/Logging/IBGLog.cs @@ -40,25 +40,25 @@ namespace DiscImageChef.Core.Logging { class IbgLog { - static FileStream ibgFs; - static StringBuilder ibgSb; - static DateTime ibgDatePoint; - static CultureInfo ibgCulture; - static double ibgStartSpeed; - static string ibgMediaType; - static double ibgDivider; - static bool ibgStartSet; - static double ibgMaxSpeed; - static double ibgIntSpeed; - static int ibgSnaps; - static ulong ibgIntSector; - static int ibgSampleRate; + StringBuilder ibgSb; + DateTime ibgDatePoint; + CultureInfo ibgCulture; + double ibgStartSpeed; + string ibgMediaType; + double ibgDivider; + bool ibgStartSet; + double ibgMaxSpeed; + double ibgIntSpeed; + int ibgSnaps; + ulong ibgIntSector; + int ibgSampleRate; + string logFile; internal IbgLog(string outputFile, ushort currentProfile) { if(string.IsNullOrEmpty(outputFile)) return; - ibgFs = new FileStream(outputFile, FileMode.Create); + logFile = outputFile; ibgSb = new StringBuilder(); ibgDatePoint = DateTime.Now; ibgCulture = new CultureInfo("en-US"); @@ -194,7 +194,7 @@ namespace DiscImageChef.Core.Logging internal void Write(ulong sector, double currentSpeed) { - if(ibgFs == null) return; + if(logFile == null) return; ibgIntSpeed += currentSpeed; ibgSampleRate += (int)Math.Floor((DateTime.Now - ibgDatePoint).TotalMilliseconds); @@ -222,8 +222,8 @@ namespace DiscImageChef.Core.Logging internal void Close(Device dev, ulong blocks, ulong blockSize, double totalSeconds, double currentSpeed, double averageSpeed, string devicePath) { - if(ibgFs == null) return; - + if(logFile == null) return; + FileStream ibgFs = new FileStream(logFile, FileMode.Create); StringBuilder ibgHeader = new StringBuilder(); string ibgBusType; diff --git a/DiscImageChef.Core/Logging/MHDDLog.cs b/DiscImageChef.Core/Logging/MHDDLog.cs index 1d7077f3a..cda3635a4 100644 --- a/DiscImageChef.Core/Logging/MHDDLog.cs +++ b/DiscImageChef.Core/Logging/MHDDLog.cs @@ -40,14 +40,16 @@ namespace DiscImageChef.Core.Logging { class MhddLog { - FileStream mhddFs; + MemoryStream mhddFs; + string logFile; internal MhddLog(string outputFile, Device dev, ulong blocks, ulong blockSize, ulong blocksToRead) { if(dev == null || string.IsNullOrEmpty(outputFile)) return; - mhddFs = new FileStream(outputFile, FileMode.Create); - + mhddFs = new MemoryStream(); + logFile = outputFile; + string mode; switch(dev.Type) @@ -123,7 +125,7 @@ namespace DiscImageChef.Core.Logging internal void Write(ulong sector, double duration) { - if(mhddFs == null) return; + if(logFile == null) return; byte[] sectorBytes = BitConverter.GetBytes(sector); byte[] durationBytes = BitConverter.GetBytes((ulong)(duration * 1000)); @@ -134,7 +136,12 @@ namespace DiscImageChef.Core.Logging internal void Close() { - if(mhddFs != null) mhddFs.Close(); + if(logFile == null) return; + + FileStream fs = new FileStream(logFile, FileMode.Create); + mhddFs.WriteTo(fs); + mhddFs.Close(); + fs.Close(); } } } \ No newline at end of file