using System; using System.Linq; using System.Web; using SabreTools.Library.DatFiles; using SabreTools.Library.Tools; #if MONO using System.IO; #else using Alphaleonis.Win32.Filesystem; using Stream = System.IO.Stream; #endif namespace SabreTools.Library.Reports { /// /// HTML report format /// public class Html : BaseReport { /// /// Create a new report from the input DatFile and the filename /// /// DatFile to write out statistics for /// 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(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false) : base(datfile, filename, baddumpCol, nodumpCol) { } /// /// Create a new report from the input DatFile and 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(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false) : base(datfile, stream, baddumpCol, nodumpCol) { } /// /// Write the report to file /// /// Number of games to use, -1 means use the number of keys public override void Write(long game = -1) { string line = "\t\t\t" + HttpUtility.HtmlEncode(_datFile.FileName.Remove(0, 5)) : ">" + HttpUtility.HtmlEncode(_datFile.FileName)) + "" + "" + Style.GetBytesReadable(_datFile.TotalSize) + "" + "" + (game == -1 ? _datFile.Keys.Count() : game) + "" + "" + _datFile.RomCount + "" + "" + _datFile.DiskCount + "" + "" + _datFile.CRCCount + "" + "" + _datFile.MD5Count + "" + "" + _datFile.SHA1Count + "" + "" + _datFile.SHA256Count + "" + (_baddumpCol ? "" + _datFile.BaddumpCount + "" : "") + (_nodumpCol ? "" + _datFile.NodumpCount + "" : "") + "\n"; _writer.Write(line); _writer.Flush(); } /// /// Write out the header to the stream, if any exists /// public override void WriteStatsHeader() { _writer.Write(@"
DAT Statistics Report

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

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