using System; using System.IO; using System.Net; using SabreTools.Library.Tools; namespace SabreTools.Library.Reports { /// /// HTML report format /// /// TODO: Make output standard width, without making the entire thing a table internal class Html : BaseReport { /// /// Create a new report from the filename /// /// Name of the file to write out to /// True if baddumps should be included in output, false otherwise /// True if nodumps should be included in output, false otherwise public Html(string filename, bool baddumpCol = false, bool nodumpCol = false) : base(filename, baddumpCol, nodumpCol) { } /// /// Create a new report from the stream /// /// DatFile to write out statistics for /// Output stream to write to /// True if baddumps should be included in output, false otherwise /// True if nodumps should be included in output, false otherwise public Html(Stream stream, bool baddumpCol = false, bool nodumpCol = false) : base(stream, baddumpCol, nodumpCol) { } /// /// Write the report to file /// public override void Write() { string line = "\t\t\t{WebUtility.HtmlEncode(_name.Remove(0, 5))}" : $">{WebUtility.HtmlEncode(_name)}") + "" + $"{Utilities.GetBytesReadable(_stats.TotalSize)}" + $"{_machineCount}" + $"{_stats.RomCount}" + $"{_stats.DiskCount}" + $"{_stats.CRCCount}" + $"{_stats.MD5Count}" #if NET_FRAMEWORK + $"{_stats.RIPEMD160Count}" #endif + $"{_stats.SHA1Count}" + $"{_stats.SHA256Count}" + (_baddumpCol ? $"{_stats.BaddumpCount}" : string.Empty) + (_nodumpCol ? $"{_stats.NodumpCount}" : string.Empty) + "\n"; _writer.Write(line); _writer.Flush(); } /// /// Write out the header to the stream, if any exists /// public override void WriteHeader() { _writer.Write(@"
DAT Statistics Report

DAT Statistics Report (" + DateTime.Now.ToShortDateString() + @")

"); _writer.Flush(); // Now write the mid header for those who need it WriteMidHeader(); } /// /// Write out the mid-header to the stream, if any exists /// public override void WriteMidHeader() { _writer.Write(@" " + @"" + (_baddumpCol ? "" : string.Empty) + (_nodumpCol ? "" : string.Empty) + "\n"); _writer.Flush(); } /// /// Write out the separator to the stream, if any exists /// public override void WriteMidSeparator() { _writer.Write("\n"); _writer.Flush(); } /// /// Write out the footer-separator to the stream, if any exists /// public override void WriteFooterSeparator() { _writer.Write("\n"); _writer.Flush(); } /// /// Write out the footer to the stream, if any exists /// public override void WriteFooter() { _writer.Write(@"
File NameTotal SizeGamesRomsDisks# with CRC# with MD5# with SHA-1# with SHA-256BaddumpsNodumps
"); _writer.Flush(); } } }