using System.IO; using SabreTools.Library.Tools; namespace SabreTools.Library.Reports { /// /// Textfile report format /// internal class Textfile : 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 Textfile(string filename, bool baddumpCol = false, bool nodumpCol = false) : base(filename, baddumpCol, nodumpCol) { } /// /// Create a new report from the stream /// /// 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 Textfile(Stream stream, bool baddumpCol = false, bool nodumpCol = false) : base(stream, baddumpCol, nodumpCol) { } /// /// Write the report to file /// public override void Write() { string line = @"'" + _name + @"': -------------------------------------------------- Uncompressed size: " + Utilities.GetBytesReadable(_stats.TotalSize) + @" Games found: " + _machineCount + @" Roms found: " + _stats.RomCount + @" Disks found: " + _stats.DiskCount + @" Roms with CRC: " + _stats.CRCCount + @" Roms with MD5: " + _stats.MD5Count #if NET_FRAMEWORK + @" Roms with RIPEMD160: " + _stats.RIPEMD160Count #endif + @" Roms with SHA-1: " + _stats.SHA1Count + @" Roms with SHA-256: " + _stats.SHA256Count + @" Roms with SHA-384: " + _stats.SHA384Count + @" Roms with SHA-512: " + _stats.SHA512Count + "\n"; if (_baddumpCol) line += " Roms with BadDump status: " + _stats.BaddumpCount + "\n"; if (_nodumpCol) line += " Roms with Nodump status: " + _stats.NodumpCount + "\n"; // For spacing between DATs line += "\n\n"; _writer.Write(line); _writer.Flush(); } /// /// Write out the header to the stream, if any exists /// public override void WriteHeader() { // This call is a no-op for textfile output } /// /// Write out the mid-header to the stream, if any exists /// public override void WriteMidHeader() { // This call is a no-op for textfile output } /// /// Write out the separator to the stream, if any exists /// public override void WriteMidSeparator() { // This call is a no-op for textfile output } /// /// 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() { // This call is a no-op for textfile output } } }