Files
SabreTools/SabreTools.DatFiles/Reports/Textfile.cs

110 lines
3.6 KiB
C#
Raw Normal View History

using System.IO;
namespace SabreTools.DatFiles.Reports
{
2019-02-08 20:53:13 -08:00
/// <summary>
/// Textfile report format
/// </summary>
internal class Textfile : BaseReport
{
/// <summary>
/// Create a new report from the filename
2019-02-08 20:53:13 -08:00
/// </summary>
/// <param name="filename">Name of the file to write out to</param>
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
public Textfile(string filename, bool baddumpCol = false, bool nodumpCol = false)
: base(filename, baddumpCol, nodumpCol)
2019-02-08 20:53:13 -08:00
{
}
2019-02-08 20:53:13 -08:00
/// <summary>
/// Create a new report from the stream
2019-02-08 20:53:13 -08:00
/// </summary>
/// <param name="stream">Output stream to write to</param>
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
public Textfile(Stream stream, bool baddumpCol = false, bool nodumpCol = false)
: base(stream, baddumpCol, nodumpCol)
2019-02-08 20:53:13 -08:00
{
}
2019-02-08 20:53:13 -08:00
/// <summary>
/// Write the report to file
/// </summary>
public override void Write()
2019-02-08 20:53:13 -08:00
{
string line = @"'" + _name + @"':
--------------------------------------------------
2020-12-08 11:09:05 -08:00
Uncompressed size: " + 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";
2019-02-08 20:53:13 -08:00
if (_baddumpCol)
line += " Roms with BadDump status: " + _stats.BaddumpCount + "\n";
2019-02-08 20:53:13 -08:00
if (_nodumpCol)
line += " Roms with Nodump status: " + _stats.NodumpCount + "\n";
2019-02-08 20:53:13 -08:00
// For spacing between DATs
line += "\n\n";
2019-02-08 20:53:13 -08:00
_writer.Write(line);
_writer.Flush();
}
2019-02-08 20:53:13 -08:00
/// <summary>
/// Write out the header to the stream, if any exists
/// </summary>
public override void WriteHeader()
{
// This call is a no-op for textfile output
}
2019-02-08 20:53:13 -08:00
/// <summary>
/// Write out the mid-header to the stream, if any exists
/// </summary>
public override void WriteMidHeader()
{
// This call is a no-op for textfile output
}
2019-02-08 20:53:13 -08:00
/// <summary>
/// Write out the separator to the stream, if any exists
/// </summary>
public override void WriteMidSeparator()
{
// This call is a no-op for textfile output
}
2019-02-08 20:53:13 -08:00
/// <summary>
/// Write out the footer-separator to the stream, if any exists
/// </summary>
public override void WriteFooterSeparator()
{
_writer.Write("\n");
_writer.Flush();
}
2019-02-08 20:53:13 -08:00
/// <summary>
/// Write out the footer to the stream, if any exists
/// </summary>
public override void WriteFooter()
{
// This call is a no-op for textfile output
}
}
}