using System.Linq; 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 { /// /// Textfile report format /// internal class Textfile : 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 Textfile(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 Textfile(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 = @"'" + _datFile.FileName + @"': -------------------------------------------------- Uncompressed size: " + Utilities.GetBytesReadable(_datFile.TotalSize) + @" Games found: " + (game == -1 ? _datFile.Keys.Count() : game) + @" Roms found: " + _datFile.RomCount + @" Disks found: " + _datFile.DiskCount + @" Roms with CRC: " + _datFile.CRCCount + @" Roms with MD5: " + _datFile.MD5Count + @" Roms with RIPEMD160: " + _datFile.RIPEMD160Count + @" Roms with SHA-1: " + _datFile.SHA1Count + @" Roms with SHA-256: " + _datFile.SHA256Count + @" Roms with SHA-384: " + _datFile.SHA384Count + @" Roms with SHA-512: " + _datFile.SHA512Count + "\n"; if (_baddumpCol) { line += " Roms with BadDump status: " + _datFile.BaddumpCount + "\n"; } if (_nodumpCol) { line += " Roms with Nodump status: " + _datFile.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 } } }