[SabreTools, Output] Add CSV output mode

This commit is contained in:
Matt Nadareski
2016-08-23 15:18:37 -07:00
parent 12f1c3aa90
commit 23634d0d58
5 changed files with 30 additions and 12 deletions

View File

@@ -159,11 +159,16 @@ namespace SabreTools.Helper
")\n";
break;
case OutputFormat.MissFile:
if (datdata.TSV)
if (datdata.TSV == true)
{
header = "File Name\tInternal Name\tDescription\tGame Name\tGame Description\tType\t" +
"Rom Name\tDisk Name\tSize\tCRC\tMD5\tSHA1\tNodump\n";
}
else if (datdata.TSV == false)
{
header = "\"File Name\",\"Internal Name\",\"Description\",\"Game Name\",\"Game Description\",\"Type\",\"" +
"Rom Name\",\"Disk Name\",\"Size\",\"CRC\",\"MD5\",\"SHA1\",\"Nodump\n";
}
break;
case OutputFormat.RomCenter:
header = "[CREDITS]\n" +
@@ -392,8 +397,8 @@ namespace SabreTools.Helper
" )\n";
break;
case OutputFormat.MissFile:
string pre = datdata.Prefix + (datdata.Quotes || datdata.TSV ? "\"" : "");
string post = (datdata.Quotes || datdata.TSV ? "\"" : "") + datdata.Postfix;
string pre = datdata.Prefix + (datdata.Quotes ? "\"" : "");
string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix;
// Check for special strings in prefix and postfix
pre = pre.Replace("%crc%", rom.CRC).Replace("%md5%", rom.MD5).Replace("%sha1%", rom.SHA1).Replace("%size%", rom.Size.ToString());
@@ -411,13 +416,21 @@ namespace SabreTools.Helper
}
}
// If we're in TSV mode, similarly the state is consistent
else if (datdata.TSV)
else if (datdata.TSV == true)
{
string inline = datdata.FileName + "\t" + datdata.Name + "\t" + datdata.Description + "\t" + rom.Game + "\t" + rom.Game + "\t" +
rom.Type + "\t" + (rom.Type == "rom" ? rom.Name : "") + "\t" + (rom.Type == "disk" ? rom.Name : "") + "\t" + rom.Size + "\t" +
rom.CRC + "\t" + rom.MD5 + "\t" + rom.SHA1 + "\t" + (rom.Nodump ? "Nodump" : "");
state += pre + inline + post + "\n";
}
// If we're in CSV mode, similarly the state is consistent
else if (datdata.TSV == false)
{
string inline = "\"" + datdata.FileName + "\",\"" + datdata.Name + "\",\"" + datdata.Description + "\",\"" + rom.Game + "\",\"" + rom.Game + "\",\"" +
rom.Type + "\",\"" + (rom.Type == "rom" ? rom.Name : "") + "\",\"" + (rom.Type == "disk" ? rom.Name : "") + "\",\"" + rom.Size + "\",\"" +
rom.CRC + "\",\"" + rom.MD5 + "\",\"" + rom.SHA1 + "\"," + (rom.Nodump ? "\"Nodump\"" : "\"\"");
state += pre + inline + post + "\n";
}
// Otherwise, use any flags
else
{