mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* LICENSE.LGPL: Added LICENSE files for LGPL and MIT licenses. * DiscImageChef.Devices/Enums.cs: * DiscImageChef.Partitions/MBR.cs: * DiscImageChef.Partitions/RDB.cs: * DiscImageChef.DiscImages/GDI.cs: * DiscImageChef.Partitions/Sun.cs: * DiscImageChef.DiscImages/VHD.cs: * DiscImageChef.Partitions/GPT.cs: * DiscImageChef.Filesystems/FFS.cs: * DiscImageChef.Filesystems/FAT.cs: * DiscImageChef.Partitions/NeXT.cs: * DiscImageChef.Devices/Command.cs: * DiscImageChef.DiscImages/Nero.cs: * DiscImageChef.Decoders/CD/PMA.cs: * DiscImageChef.Decoders/CD/TOC.cs: * DiscImageChef.Filesystems/BFS.cs: * DiscImageChef.Filesystems/ODS.cs: * DiscImageChef.Helpers/PrintHex.cs: * DiscImageChef.Helpers/Swapping.cs: * DiscImageChef.Decoders/DVD/PRI.cs: * DiscImageChef.Decoders/DVD/DMI.cs: * DiscImageChef.Decoders/DVD/DDS.cs: * DiscImageChef.Decoders/DVD/RMD.cs: * DiscImageChef.Decoders/DVD/UDI.cs: * DiscImageChef.Partitions/Atari.cs: * DiscImageChef.Decoders/DVD/BCA.cs: * DiscImageChef.Filesystems/SysV.cs: * DiscImageChef.Filesystems/HPFS.cs: * DiscImageChef.Filesystems/NTFS.cs: * DiscImageChef.Filesystems/APFS.cs: * DiscImageChef.Decoders/DVD/PFI.cs: * DiscImageChef.Decoders/CD/ATIP.cs: * DiscImageChef.Filesystems/Acorn.cs: * DiscImageChef.DiscImages/CDRWin.cs: * DiscImageChef.DiscImages/CDRDAO.cs: * DiscImageChef.Filesystems/BTRFS.cs: * DiscImageChef.Decoders/Xbox/DMI.cs: * DiscImageChef.Helpers/ArrayFill.cs: * DiscImageChef.Settings/Settings.cs: * DiscImageChef.Filesystems/Opera.cs: * DiscImageChef.Filesystems/extFS.cs: * DiscImageChef.Decoders/DVD/CPRM.cs: * DiscImageChef.Decoders/DVD/ADIP.cs: * DiscImageChef.Decoders/CD/Enums.cs: * DiscImageChef.Decoders/DVD/AACS.cs: * DiscImageChef.Decoders/SCSI/EVPD.cs: * DiscImageChef.Filesystems/ProDOS.cs: * DiscImageChef.Metadata/MediaType.cs: * DiscImageChef.Console/DicConsole.cs: * DiscImageChef.Decoders/DVD/Spare.cs: * DiscImageChef.Filesystems/ext2FS.cs: * DiscImageChef.Decoders/DVD/Enums.cs: * DiscImageChef.Filesystems/Symbian.cs: * DiscImageChef.Decoders/SCSI/Types.cs: * DiscImageChef.Filesystems/UNIXBFS.cs: * DiscImageChef.DiscImages/TeleDisk.cs: * DiscImageChef.Decoders/SCSI/Sense.cs: * DiscImageChef.Decoders/CD/FullTOC.cs: * DiscImageChef.Decoders/Blu-ray/DI.cs: * DiscImageChef.Decoders/ATA/Errors.cs: * DiscImageChef.Filesystems/ISO9660.cs: * DiscImageChef.Filesystems/MinixFS.cs: * DiscImageChef.Devices/Linux/Enums.cs: * DiscImageChef.Filesystems/SolarFS.cs: * DiscImageChef.Filesystems/Structs.cs: * DiscImageChef.DiscImages/Apple2MG.cs: * DiscImageChef.Decoders/SCSI/Modes.cs: * DiscImageChef.Metadata/Dimensions.cs: * DiscImageChef.Partitions/AppleMap.cs: * DiscImageChef.Decoders/Floppy/ISO.cs: * DiscImageChef.Decoders/DVD/Layers.cs: * DiscImageChef.Decoders/CD/Session.cs: * DiscImageChef.Decoders/SCSI/Enums.cs: * DiscImageChef.Filesystems/Nintendo.cs: * DiscImageChef.Helpers/DateHandlers.cs: * DiscImageChef.Filesystems/AmigaDOS.cs: * DiscImageChef.DiscImages/ImageInfo.cs: * DiscImageChef.Checksums/MD5Context.cs: * DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Filesystems/AppleHFS.cs: * DiscImageChef.Filesystems/AppleMFS.cs: * DiscImageChef.Helpers/ArrayIsEmpty.cs: * DiscImageChef.Decoders/Blu-ray/BCA.cs: * DiscImageChef.Decoders/Blu-ray/DDS.cs: * DiscImageChef.Filesystems/PCEngine.cs: * DiscImageChef.Decoders/ATA/Identify.cs: * DiscImageChef.Devices/Linux/Command.cs: * DiscImageChef.Devices/FreeBSD/Enums.cs: * DiscImageChef.Decoders/SCSI/Inquiry.cs: * DiscImageChef.Metadata/DeviceReport.cs: * DiscImageChef.Decoders/Floppy/Amiga.cs: * DiscImageChef.Devices/Linux/Structs.cs: * DiscImageChef.Devices/Windows/Enums.cs: * DiscImageChef.Decoders/DVD/CSS&CPRM.cs: * DiscImageChef.Checksums/SHA1Context.cs: * DiscImageChef.DiscImages/DiskCopy42.cs: * DiscImageChef.Partitions/PartPlugin.cs: * DiscImageChef.CommonTypes/Partition.cs: * DiscImageChef.Decoders/Floppy/Enums.cs: * DiscImageChef.CommonTypes/MediaType.cs: * DiscImageChef.Decoders/Floppy/Apple2.cs: * DiscImageChef.Devices/Windows/Extern.cs: * DiscImageChef.Decoders/SCSI/MMC/CPRM.cs: * DiscImageChef.Helpers/StringHandlers.cs: * DiscImageChef.DiscImages/ImagePlugin.cs: * DiscImageChef.Checksums/CRC64Context.cs: * DiscImageChef.Checksums/CRC32Context.cs: * DiscImageChef.DiscImages/ZZZRawImage.cs: * DiscImageChef.Checksums/CRC16Context.cs: * DiscImageChef.Filesystems/LisaFS/Dir.cs: * DiscImageChef.Decoders/DVD/Cartridge.cs: * DiscImageChef.Decoders/Blu-ray/Spare.cs: * DiscImageChef.Filesystems/Filesystem.cs: * DiscImageChef.Decoders/SCSI/MMC/AACS.cs: * DiscImageChef.Devices/FreeBSD/Extern.cs: * DiscImageChef.Devices/Device/Commands.cs: * DiscImageChef.Checksums/SHA384Context.cs: * DiscImageChef.Devices/FreeBSD/Command.cs: * DiscImageChef.Checksums/SHA512Context.cs: * DiscImageChef.Decoders/SCSI/MMC/Enums.cs: * DiscImageChef.Devices/Windows/Command.cs: * DiscImageChef.Devices/FreeBSD/Structs.cs: * DiscImageChef.Devices/Windows/Structs.cs: * DiscImageChef.Filesystems/LisaFS/Info.cs: * DiscImageChef.Checksums/SHA256Context.cs: * DiscImageChef.Filesystems/LisaFS/File.cs: * DiscImageChef.Filesystems/AppleHFSPlus.cs: * DiscImageChef.Filesystems/LisaFS/Super.cs: * DiscImageChef.Filesystems/LisaFS/Xattr.cs: * DiscImageChef.Checksums/Adler32Context.cs: * DiscImageChef.Decoders/Floppy/System34.cs: * DiscImageChef.Checksums/SpamSumContext.cs: * DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs: * DiscImageChef.Devices/Device/Variables.cs: * DiscImageChef.Filesystems/LisaFS/Consts.cs: * DiscImageChef.Filesystems/LisaFS/LisaFS.cs: * DiscImageChef.Decoders/Floppy/Commodore.cs: * DiscImageChef.Checksums/FletcherContext.cs: * DiscImageChef.Filesystems/LisaFS/Extent.cs: * DiscImageChef.Devices/Device/Destructor.cs: * DiscImageChef.Decoders/Floppy/AppleSony.cs: * DiscImageChef.Filesystems/LisaFS/Structs.cs: * DiscImageChef.Decoders/SCSI/VendorString.cs: * DiscImageChef.Decoders/SCSI/MMC/Features.cs: * DiscImageChef.Devices/Device/Constructor.cs: * DiscImageChef.Checksums/RIPEMD160Context.cs: * DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs: * DiscImageChef.Decoders/Blu-ray/Cartridge.cs: * DiscImageChef.Decoders/Floppy/System3740.cs: * DiscImageChef.Filesystems/LisaFS/Encoding.cs: * DiscImageChef.Decoders/SCSI/ModesEncoders.cs: * DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs: * DiscImageChef.Helpers/BigEndianBitConverter.cs: * DiscImageChef.Decoders/Floppy/Perpendicular.cs: * DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs: * DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs: * DiscImageChef.Devices/Device/ScsiCommands/HP.cs: * DiscImageChef.Devices/Device/AtaCommands/Cfa.cs: * DiscImageChef.Devices/Device/ScsiCommands/NEC.cs: * DiscImageChef.Helpers/EndianAwareBinaryReader.cs: * DiscImageChef.Devices/Device/ScsiCommands/MMC.cs: * DiscImageChef.Devices/Device/AtaCommands/MCPT.cs: * DiscImageChef.Devices/Device/ScsiCommands/SSC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SPC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SMC.cs: * DiscImageChef.Devices/Device/ScsiCommands/SBC.cs: * DiscImageChef.Metadata/Properties/AssemblyInfo.cs: * DiscImageChef.Devices/Device/AtaCommands/Atapi.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata28.cs: * DiscImageChef.Devices/Device/AtaCommands/Smart.cs: * DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs: * DiscImageChef.Devices/Device/AtaCommands/Ata48.cs: * DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs: * DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs: * DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs: * DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs: * DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs: * DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs: * DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs: * DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs: * DiscImageChef.Devices/Device/ScsiCommands/Certance.cs: * DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs: * DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs: Relicensed as LGPL. Updated standard header. * DiscImageChef/Main.cs: * DiscImageChef/Plugins.cs: * DiscImageChef/Options.cs: * DiscImageChef/Commands/Ls.cs: * DiscImageChef/Core/IBGLog.cs: * DiscImageChef/Core/MHDDLog.cs: * DiscImageChef/AssemblyInfo.cs: * DiscImageChef/Core/Checksum.cs: * DiscImageChef/Commands/Decode.cs: * DiscImageChef/Core/Statistics.cs: * DiscImageChef/Commands/Verify.cs: * DiscImageChef/Commands/Formats.cs: * DiscImageChef/Commands/Entropy.cs: * DiscImageChef/Commands/Compare.cs: * DiscImageChef.Interop/DetectOS.cs: * DiscImageChef/Commands/Analyze.cs: * DiscImageChef/Commands/Commands.cs: * DiscImageChef/Commands/PrintHex.cs: * DiscImageChef/Commands/Checksum.cs: * DiscImageChef/DetectImageFormat.cs: * DiscImageChef/Commands/DumpMedia.cs: * DiscImageChef/Commands/Benchmark.cs: * DiscImageChef/Commands/Configure.cs: * DiscImageChef/Commands/MediaInfo.cs: * DiscImageChef.Interop/PlatformID.cs: * DiscImageChef/Commands/MediaScan.cs: * DiscImageChef/Commands/Statistics.cs: * DiscImageChef/Commands/DeviceInfo.cs: * DiscImageChef.Checksums/ReedSolomon.cs: * DiscImageChef/Commands/DeviceReport.cs: * DiscImageChef/Commands/ExtractFiles.cs: * DiscImageChef.Checksums/CDChecksums.cs: * DiscImageChef/Commands/CreateSidecar.cs: Updated standard header. * DiscImageChef.Checksums/DiscImageChef.Checksums.csproj: Relicensed project as LGPL. Updated standard header. Embed license as resource. * DiscImageChef.Console/DiscImageChef.Console.csproj: * DiscImageChef.Devices/DiscImageChef.Devices.csproj: * DiscImageChef.Helpers/DiscImageChef.Helpers.csproj: * DiscImageChef.Settings/DiscImageChef.Settings.csproj: * DiscImageChef.Decoders/DiscImageChef.Decoders.csproj: * DiscImageChef.Metadata/DiscImageChef.Metadata.csproj: * DiscImageChef.Partitions/DiscImageChef.Partitions.csproj: * DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj: * DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj: * DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj: Relicensed as LGPL. Updated standard header. Embed license as resource. * DiscImageChef/DiscImageChef.csproj: * DiscImageChef.Interop/DiscImageChef.Interop.csproj: Updated standard header. Embed license as resource.
721 lines
25 KiB
C#
721 lines
25 KiB
C#
// /***************************************************************************
|
|
// The Disc Image Chef
|
|
// ----------------------------------------------------------------------------
|
|
//
|
|
// Filename : Statistics.cs
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
//
|
|
// Component : Core methods.
|
|
//
|
|
// --[ Description ] ----------------------------------------------------------
|
|
//
|
|
// Methods to handle statistics.
|
|
//
|
|
// --[ License ] --------------------------------------------------------------
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
//
|
|
// ----------------------------------------------------------------------------
|
|
// Copyright © 2011-2016 Natalia Portillo
|
|
// ****************************************************************************/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace DiscImageChef.Core
|
|
{
|
|
[XmlRoot("DicStats", Namespace = "", IsNullable = false)]
|
|
public class Stats
|
|
{
|
|
public CommandsStats Commands;
|
|
[XmlArrayItem("Filesystem")]
|
|
public List<NameValueStats> Filesystems;
|
|
[XmlArrayItem("Scheme")]
|
|
public List<NameValueStats> Partitions;
|
|
[XmlArrayItem("Format")]
|
|
public List<NameValueStats> MediaImages;
|
|
[XmlArrayItem("Device", IsNullable = true)]
|
|
public List<DeviceStats> Devices;
|
|
[XmlArrayItem("Media")]
|
|
public List<MediaStats> Medias;
|
|
public BenchmarkStats Benchmark;
|
|
public MediaScanStats MediaScan;
|
|
public VerifyStats Verify;
|
|
}
|
|
|
|
public class CommandsStats
|
|
{
|
|
public long Analyze;
|
|
public long Benchmark;
|
|
public long Checksum;
|
|
public long Compare;
|
|
public long CreateSidecar;
|
|
public long Decode;
|
|
public long DeviceInfo;
|
|
public long DeviceReport;
|
|
public long DumpMedia;
|
|
public long Entropy;
|
|
public long Formats;
|
|
public long MediaInfo;
|
|
public long MediaScan;
|
|
public long PrintHex;
|
|
public long Verify;
|
|
}
|
|
|
|
public class VerifiedItems
|
|
{
|
|
public long Correct;
|
|
public long Failed;
|
|
}
|
|
|
|
public class VerifyStats
|
|
{
|
|
public VerifiedItems MediaImages;
|
|
public ScannedSectors Sectors;
|
|
}
|
|
|
|
public class ScannedSectors
|
|
{
|
|
public long Total;
|
|
public long Error;
|
|
public long Correct;
|
|
public long Unverifiable;
|
|
}
|
|
|
|
public class TimeStats
|
|
{
|
|
public long LessThan3ms;
|
|
public long LessThan10ms;
|
|
public long LessThan50ms;
|
|
public long LessThan150ms;
|
|
public long LessThan500ms;
|
|
public long MoreThan500ms;
|
|
}
|
|
|
|
public class MediaScanStats
|
|
{
|
|
public ScannedSectors Sectors;
|
|
public TimeStats Times;
|
|
}
|
|
|
|
public class ChecksumStats
|
|
{
|
|
[XmlAttribute]
|
|
public string algorithm;
|
|
[XmlText]
|
|
public double Value;
|
|
}
|
|
|
|
public class BenchmarkStats
|
|
{
|
|
[XmlElement("Checksum")]
|
|
public List<ChecksumStats> Checksum;
|
|
public double Entropy;
|
|
public double All;
|
|
public double Sequential;
|
|
public long MaxMemory;
|
|
public long MinMemory;
|
|
}
|
|
|
|
public class MediaStats
|
|
{
|
|
[XmlAttribute]
|
|
public bool real;
|
|
[XmlAttribute]
|
|
public string type;
|
|
[XmlText]
|
|
public long Value;
|
|
}
|
|
|
|
public class DeviceStats
|
|
{
|
|
public string Manufacturer;
|
|
public string Model;
|
|
public string Revision;
|
|
public string Bus;
|
|
|
|
[XmlIgnore]
|
|
public bool ManufacturerSpecified;
|
|
}
|
|
|
|
public class NameValueStats
|
|
{
|
|
[XmlAttribute]
|
|
public string name;
|
|
[XmlText]
|
|
public long Value;
|
|
}
|
|
|
|
public static class Statistics
|
|
{
|
|
public static Stats AllStats;
|
|
public static Stats CurrentStats;
|
|
|
|
public static void LoadStats()
|
|
{
|
|
if(File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")))
|
|
{
|
|
AllStats = new Stats();
|
|
CurrentStats = new Stats();
|
|
|
|
XmlSerializer xs = new XmlSerializer(AllStats.GetType());
|
|
StreamReader sr = new StreamReader(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"));
|
|
AllStats = (Stats)xs.Deserialize(sr);
|
|
sr.Close();
|
|
}
|
|
else if(Settings.Settings.Current.Stats != null)
|
|
{
|
|
AllStats = new Stats();
|
|
CurrentStats = new Stats();
|
|
}
|
|
else
|
|
{
|
|
AllStats = null;
|
|
CurrentStats = null;
|
|
}
|
|
}
|
|
|
|
public static void SaveStats()
|
|
{
|
|
if(AllStats != null)
|
|
{
|
|
FileStream fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"), FileMode.Create);
|
|
XmlSerializer xs = new XmlSerializer(AllStats.GetType());
|
|
xs.Serialize(fs, AllStats);
|
|
fs.Close();
|
|
|
|
if(CurrentStats != null)
|
|
{
|
|
string partial = string.Format("PartialStats_{0:yyyyMMddHHmmssfff}.xml", DateTime.UtcNow);
|
|
|
|
fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, partial), FileMode.Create);
|
|
xs = new XmlSerializer(CurrentStats.GetType());
|
|
xs.Serialize(fs, CurrentStats);
|
|
fs.Close();
|
|
}
|
|
|
|
if(Settings.Settings.Current.Stats.ShareStats)
|
|
SubmitStats();
|
|
}
|
|
}
|
|
|
|
public static void SubmitStats()
|
|
{
|
|
// TODO: Implement it
|
|
}
|
|
|
|
public static void AddCommand(string command)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.DeviceStats)
|
|
{
|
|
if(AllStats.Commands == null)
|
|
AllStats.Commands = new CommandsStats();
|
|
|
|
if(CurrentStats.Commands == null)
|
|
CurrentStats.Commands = new CommandsStats();
|
|
|
|
switch(command)
|
|
{
|
|
case "analyze":
|
|
AllStats.Commands.Analyze++;
|
|
CurrentStats.Commands.Analyze++;
|
|
break;
|
|
case "benchmark":
|
|
AllStats.Commands.Benchmark++;
|
|
CurrentStats.Commands.Benchmark++;
|
|
break;
|
|
case "checksum":
|
|
AllStats.Commands.Checksum++;
|
|
CurrentStats.Commands.Checksum++;
|
|
break;
|
|
case "compare":
|
|
AllStats.Commands.Compare++;
|
|
CurrentStats.Commands.Compare++;
|
|
break;
|
|
case "create-sidecar":
|
|
AllStats.Commands.CreateSidecar++;
|
|
CurrentStats.Commands.CreateSidecar++;
|
|
break;
|
|
case "decode":
|
|
AllStats.Commands.Decode++;
|
|
CurrentStats.Commands.Decode++;
|
|
break;
|
|
case "device-info":
|
|
AllStats.Commands.DeviceInfo++;
|
|
CurrentStats.Commands.DeviceInfo++;
|
|
break;
|
|
case "device-report":
|
|
AllStats.Commands.DeviceReport++;
|
|
CurrentStats.Commands.DeviceReport++;
|
|
break;
|
|
case "dump-media":
|
|
AllStats.Commands.DumpMedia++;
|
|
CurrentStats.Commands.DumpMedia++;
|
|
break;
|
|
case "entropy":
|
|
AllStats.Commands.Entropy++;
|
|
CurrentStats.Commands.Entropy++;
|
|
break;
|
|
case "formats":
|
|
AllStats.Commands.Formats++;
|
|
CurrentStats.Commands.Formats++;
|
|
break;
|
|
case "media-info":
|
|
AllStats.Commands.MediaInfo++;
|
|
CurrentStats.Commands.MediaInfo++;
|
|
break;
|
|
case "media-scan":
|
|
AllStats.Commands.MediaScan++;
|
|
CurrentStats.Commands.MediaScan++;
|
|
break;
|
|
case "print-hex":
|
|
AllStats.Commands.PrintHex++;
|
|
CurrentStats.Commands.PrintHex++;
|
|
break;
|
|
case "verify":
|
|
AllStats.Commands.Verify++;
|
|
CurrentStats.Commands.Verify++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void AddFilesystem(string filesystem)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.FilesystemStats)
|
|
{
|
|
if(AllStats.Filesystems == null)
|
|
AllStats.Filesystems = new List<NameValueStats>();
|
|
if(CurrentStats.Filesystems == null)
|
|
CurrentStats.Filesystems = new List<NameValueStats>();
|
|
|
|
NameValueStats old = null;
|
|
foreach(NameValueStats nvs in AllStats.Filesystems)
|
|
{
|
|
if(nvs.name == filesystem)
|
|
{
|
|
old = nvs;
|
|
break;
|
|
}
|
|
}
|
|
|
|
NameValueStats nw = new NameValueStats();
|
|
if(old != null)
|
|
{
|
|
nw.name = old.name;
|
|
nw.Value = old.Value + 1;
|
|
AllStats.Filesystems.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.name = filesystem;
|
|
nw.Value = 1;
|
|
}
|
|
AllStats.Filesystems.Add(nw);
|
|
|
|
old = null;
|
|
foreach(NameValueStats nvs in CurrentStats.Filesystems)
|
|
{
|
|
if(nvs.name == filesystem)
|
|
{
|
|
old = nvs;
|
|
break;
|
|
}
|
|
}
|
|
|
|
nw = new NameValueStats();
|
|
if(old != null)
|
|
{
|
|
nw.name = old.name;
|
|
nw.Value = old.Value + 1;
|
|
CurrentStats.Filesystems.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.name = filesystem;
|
|
nw.Value = 1;
|
|
}
|
|
CurrentStats.Filesystems.Add(nw);
|
|
}
|
|
}
|
|
|
|
public static void AddPartition(string partition)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.PartitionStats)
|
|
{
|
|
if(AllStats.Partitions == null)
|
|
AllStats.Partitions = new List<NameValueStats>();
|
|
if(CurrentStats.Partitions == null)
|
|
CurrentStats.Partitions = new List<NameValueStats>();
|
|
|
|
NameValueStats old = null;
|
|
foreach(NameValueStats nvs in AllStats.Partitions)
|
|
{
|
|
if(nvs.name == partition)
|
|
{
|
|
old = nvs;
|
|
break;
|
|
}
|
|
}
|
|
|
|
NameValueStats nw = new NameValueStats();
|
|
if(old != null)
|
|
{
|
|
nw.name = old.name;
|
|
nw.Value = old.Value + 1;
|
|
AllStats.Partitions.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.name = partition;
|
|
nw.Value = 1;
|
|
}
|
|
AllStats.Partitions.Add(nw);
|
|
|
|
old = null;
|
|
foreach(NameValueStats nvs in CurrentStats.Partitions)
|
|
{
|
|
if(nvs.name == partition)
|
|
{
|
|
old = nvs;
|
|
break;
|
|
}
|
|
}
|
|
|
|
nw = new NameValueStats();
|
|
if(old != null)
|
|
{
|
|
nw.name = old.name;
|
|
nw.Value = old.Value + 1;
|
|
CurrentStats.Partitions.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.name = partition;
|
|
nw.Value = 1;
|
|
}
|
|
CurrentStats.Partitions.Add(nw);
|
|
}
|
|
}
|
|
|
|
public static void AddMediaFormat(string format)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaImageStats)
|
|
{
|
|
if(AllStats.MediaImages == null)
|
|
AllStats.MediaImages = new List<NameValueStats>();
|
|
if(CurrentStats.MediaImages == null)
|
|
CurrentStats.MediaImages = new List<NameValueStats>();
|
|
|
|
NameValueStats old = null;
|
|
foreach(NameValueStats nvs in AllStats.MediaImages)
|
|
{
|
|
if(nvs.name == format)
|
|
{
|
|
old = nvs;
|
|
break;
|
|
}
|
|
}
|
|
|
|
NameValueStats nw = new NameValueStats();
|
|
if(old != null)
|
|
{
|
|
nw.name = old.name;
|
|
nw.Value = old.Value + 1;
|
|
AllStats.MediaImages.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.name = format;
|
|
nw.Value = 1;
|
|
}
|
|
AllStats.MediaImages.Add(nw);
|
|
|
|
old = null;
|
|
foreach(NameValueStats nvs in CurrentStats.MediaImages)
|
|
{
|
|
if(nvs.name == format)
|
|
{
|
|
old = nvs;
|
|
break;
|
|
}
|
|
}
|
|
|
|
nw = new NameValueStats();
|
|
if(old != null)
|
|
{
|
|
nw.name = old.name;
|
|
nw.Value = old.Value + 1;
|
|
CurrentStats.MediaImages.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.name = format;
|
|
nw.Value = 1;
|
|
}
|
|
CurrentStats.MediaImages.Add(nw);
|
|
}
|
|
}
|
|
|
|
public static void AddDevice(Devices.Device dev)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.DeviceStats)
|
|
{
|
|
if(AllStats.Devices == null)
|
|
AllStats.Devices = new List<DeviceStats>();
|
|
if(CurrentStats.Devices == null)
|
|
CurrentStats.Devices = new List<DeviceStats>();
|
|
|
|
string deviceBus;
|
|
if(dev.IsUSB)
|
|
deviceBus = "USB";
|
|
else if(dev.IsFireWire)
|
|
deviceBus = "FireWire";
|
|
else
|
|
deviceBus = dev.Type.ToString();
|
|
|
|
DeviceStats old = null;
|
|
foreach(DeviceStats ds in AllStats.Devices)
|
|
{
|
|
if(ds.Manufacturer == dev.Manufacturer &&
|
|
ds.Model == dev.Model &&
|
|
ds.Revision == dev.Revision &&
|
|
ds.Bus == deviceBus)
|
|
{
|
|
old = ds;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(old != null)
|
|
AllStats.Devices.Remove(old);
|
|
|
|
DeviceStats nw = new DeviceStats();
|
|
nw.Model = dev.Model;
|
|
nw.Manufacturer = dev.Manufacturer;
|
|
nw.Revision = dev.Revision;
|
|
nw.Bus = deviceBus;
|
|
nw.ManufacturerSpecified = true;
|
|
AllStats.Devices.Add(nw);
|
|
|
|
old = null;
|
|
foreach(DeviceStats ds in CurrentStats.Devices)
|
|
{
|
|
if(ds.Manufacturer == dev.Manufacturer &&
|
|
ds.Model == dev.Model &&
|
|
ds.Revision == dev.Revision &&
|
|
ds.Bus == deviceBus)
|
|
{
|
|
old = ds;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(old != null)
|
|
CurrentStats.Devices.Remove(old);
|
|
|
|
nw = new DeviceStats();
|
|
nw.Model = dev.Model;
|
|
nw.Manufacturer = dev.Manufacturer;
|
|
nw.Revision = dev.Revision;
|
|
nw.Bus = deviceBus;
|
|
nw.ManufacturerSpecified = true;
|
|
CurrentStats.Devices.Add(nw);
|
|
}
|
|
}
|
|
|
|
public static void AddMedia(CommonTypes.MediaType type, bool real)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaStats)
|
|
{
|
|
if(AllStats.Medias == null)
|
|
AllStats.Medias = new List<MediaStats>();
|
|
if(CurrentStats.Medias == null)
|
|
CurrentStats.Medias = new List<MediaStats>();
|
|
|
|
MediaStats old = null;
|
|
foreach(MediaStats ms in AllStats.Medias)
|
|
{
|
|
if(ms.real == real && ms.type == type.ToString())
|
|
{
|
|
old = ms;
|
|
break;
|
|
}
|
|
}
|
|
|
|
MediaStats nw = new MediaStats();
|
|
if(old != null)
|
|
{
|
|
nw.type = old.type;
|
|
nw.real = old.real;
|
|
nw.Value = old.Value + 1;
|
|
AllStats.Medias.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.type = type.ToString();
|
|
nw.real = real;
|
|
nw.Value = 1;
|
|
}
|
|
AllStats.Medias.Add(nw);
|
|
|
|
old = null;
|
|
foreach(MediaStats ms in CurrentStats.Medias)
|
|
{
|
|
if(ms.real == real && ms.type == type.ToString())
|
|
{
|
|
old = ms;
|
|
break;
|
|
}
|
|
}
|
|
|
|
nw = new MediaStats();
|
|
if(old != null)
|
|
{
|
|
nw.type = old.type;
|
|
nw.real = old.real;
|
|
nw.Value = old.Value + 1;
|
|
CurrentStats.Medias.Remove(old);
|
|
}
|
|
else
|
|
{
|
|
nw.type = type.ToString();
|
|
nw.real = real;
|
|
nw.Value = 1;
|
|
}
|
|
CurrentStats.Medias.Add(nw);
|
|
}
|
|
}
|
|
|
|
public static void AddBenchmark(Dictionary<string, double> checksums, double entropy, double all, double sequential, long maxMemory, long minMemory)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.BenchmarkStats)
|
|
{
|
|
CurrentStats.Benchmark = new BenchmarkStats();
|
|
CurrentStats.Benchmark.Checksum = new List<ChecksumStats>();
|
|
AllStats.Benchmark = new BenchmarkStats();
|
|
AllStats.Benchmark.Checksum = new List<ChecksumStats>();
|
|
|
|
foreach(KeyValuePair<string, double> kvp in checksums)
|
|
{
|
|
ChecksumStats st = new ChecksumStats();
|
|
st.algorithm = kvp.Key;
|
|
st.Value = kvp.Value;
|
|
CurrentStats.Benchmark.Checksum.Add(st);
|
|
AllStats.Benchmark.Checksum.Add(st);
|
|
}
|
|
|
|
CurrentStats.Benchmark.All = all;
|
|
CurrentStats.Benchmark.Entropy = entropy;
|
|
CurrentStats.Benchmark.MaxMemory = maxMemory;
|
|
CurrentStats.Benchmark.MinMemory = minMemory;
|
|
CurrentStats.Benchmark.Sequential = sequential;
|
|
|
|
AllStats.Benchmark.All = all;
|
|
AllStats.Benchmark.Entropy = entropy;
|
|
AllStats.Benchmark.MaxMemory = maxMemory;
|
|
AllStats.Benchmark.MinMemory = minMemory;
|
|
AllStats.Benchmark.Sequential = sequential;
|
|
}
|
|
}
|
|
|
|
public static void AddVerify(bool? mediaVerified, long correct, long failed, long unknown, long total)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.VerifyStats)
|
|
{
|
|
if(CurrentStats.Verify == null)
|
|
{
|
|
CurrentStats.Verify = new VerifyStats();
|
|
CurrentStats.Verify.MediaImages = new VerifiedItems();
|
|
CurrentStats.Verify.Sectors = new ScannedSectors();
|
|
}
|
|
|
|
if(AllStats.Verify == null)
|
|
{
|
|
AllStats.Verify = new VerifyStats();
|
|
AllStats.Verify.MediaImages = new VerifiedItems();
|
|
AllStats.Verify.Sectors = new ScannedSectors();
|
|
}
|
|
|
|
if(mediaVerified.HasValue)
|
|
{
|
|
if(mediaVerified.Value)
|
|
{
|
|
CurrentStats.Verify.MediaImages.Correct++;
|
|
AllStats.Verify.MediaImages.Correct++;
|
|
}
|
|
else
|
|
{
|
|
CurrentStats.Verify.MediaImages.Failed++;
|
|
AllStats.Verify.MediaImages.Failed++;
|
|
}
|
|
}
|
|
|
|
CurrentStats.Verify.Sectors.Correct += correct;
|
|
CurrentStats.Verify.Sectors.Error += failed;
|
|
CurrentStats.Verify.Sectors.Unverifiable += unknown;
|
|
CurrentStats.Verify.Sectors.Total += total;
|
|
|
|
AllStats.Verify.Sectors.Correct += correct;
|
|
AllStats.Verify.Sectors.Error += failed;
|
|
AllStats.Verify.Sectors.Unverifiable += unknown;
|
|
AllStats.Verify.Sectors.Total += total;
|
|
}
|
|
}
|
|
|
|
public static void AddMediaScan(long lessThan3ms, long lessThan10ms, long lessThan50ms, long lessThan150ms, long lessThan500ms, long moreThan500ms, long total, long error, long correct)
|
|
{
|
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.MediaScanStats)
|
|
{
|
|
if(CurrentStats.MediaScan == null)
|
|
{
|
|
CurrentStats.MediaScan = new MediaScanStats();
|
|
CurrentStats.MediaScan.Sectors = new ScannedSectors();
|
|
CurrentStats.MediaScan.Times = new TimeStats();
|
|
}
|
|
|
|
if(AllStats.MediaScan == null)
|
|
{
|
|
AllStats.MediaScan = new MediaScanStats();
|
|
AllStats.MediaScan.Sectors = new ScannedSectors();
|
|
AllStats.MediaScan.Times = new TimeStats();
|
|
}
|
|
|
|
CurrentStats.MediaScan.Sectors.Correct += correct;
|
|
CurrentStats.MediaScan.Sectors.Error += error;
|
|
CurrentStats.MediaScan.Sectors.Total += total;
|
|
CurrentStats.MediaScan.Times.LessThan3ms += lessThan3ms;
|
|
CurrentStats.MediaScan.Times.LessThan10ms += lessThan10ms;
|
|
CurrentStats.MediaScan.Times.LessThan50ms += lessThan50ms;
|
|
CurrentStats.MediaScan.Times.LessThan150ms += lessThan150ms;
|
|
CurrentStats.MediaScan.Times.LessThan500ms += lessThan500ms;
|
|
CurrentStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
|
|
|
|
AllStats.MediaScan.Sectors.Correct += correct;
|
|
AllStats.MediaScan.Sectors.Error += error;
|
|
AllStats.MediaScan.Sectors.Total += total;
|
|
AllStats.MediaScan.Times.LessThan3ms += lessThan3ms;
|
|
AllStats.MediaScan.Times.LessThan10ms += lessThan10ms;
|
|
AllStats.MediaScan.Times.LessThan50ms += lessThan50ms;
|
|
AllStats.MediaScan.Times.LessThan150ms += lessThan150ms;
|
|
AllStats.MediaScan.Times.LessThan500ms += lessThan500ms;
|
|
AllStats.MediaScan.Times.MoreThan500ms += moreThan500ms;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|