[ALL] TSV and CSV are top level now

This commit is contained in:
Matt Nadareski
2016-10-04 12:12:26 -07:00
parent 134cb9a45a
commit 7797a3ec37
8 changed files with 316 additions and 128 deletions

View File

@@ -111,7 +111,9 @@ namespace SabreTools.Helper
helptext.Add(" -b, --bare Don't include date in file name"); helptext.Add(" -b, --bare Don't include date in file name");
helptext.Add(" -u, --unzip Force unzipping in created DAT"); helptext.Add(" -u, --unzip Force unzipping in created DAT");
helptext.Add(" -f, --files Treat archives as files"); helptext.Add(" -f, --files Treat archives as files");
helptext.Add(" -oa, --output-all Output in all formats");
helptext.Add(" -oc, --output-cmp Output in CMP format"); helptext.Add(" -oc, --output-cmp Output in CMP format");
helptext.Add(" -ocsv, --output-csv Output in CSV format");
helptext.Add(" -od, --output-dc Output in DOSCenter format"); helptext.Add(" -od, --output-dc Output in DOSCenter format");
helptext.Add(" -om, --output-miss Output in Missfile format"); helptext.Add(" -om, --output-miss Output in Missfile format");
helptext.Add(" -omd5, --output-md5 Output in MD5 format"); helptext.Add(" -omd5, --output-md5 Output in MD5 format");
@@ -121,6 +123,7 @@ namespace SabreTools.Helper
helptext.Add(" -osfv, --ouput-sfv Output in SFV format"); helptext.Add(" -osfv, --ouput-sfv Output in SFV format");
helptext.Add(" -osha1, --output-sha1 Output in SHA-1 format"); helptext.Add(" -osha1, --output-sha1 Output in SHA-1 format");
helptext.Add(" -osl, --output-sl Output in Softwarelist format"); helptext.Add(" -osl, --output-sl Output in Softwarelist format");
helptext.Add(" -otsv, --output-tsv Output in TSV format");
helptext.Add(" -ox, --output-xml Output in Logiqx XML format"); helptext.Add(" -ox, --output-xml Output in Logiqx XML format");
helptext.Add(" -gz, --gz-files Allow reading of GZIP files as archives"); helptext.Add(" -gz, --gz-files Allow reading of GZIP files as archives");
helptext.Add(" -ro, --romba Read files from a Romba input"); helptext.Add(" -ro, --romba Read files from a Romba input");
@@ -158,7 +161,12 @@ namespace SabreTools.Helper
helptext.Add(" -ts, --type-split Split a DAT or folder by file types (rom/disk)"); helptext.Add(" -ts, --type-split Split a DAT or folder by file types (rom/disk)");
helptext.Add(" -out= Output directory"); helptext.Add(" -out= Output directory");
helptext.Add(" -ud, --update Update a DAT file"); helptext.Add(" -ud, --update Update a DAT file");
helptext.Add(" -oa, --output-all Output in all formats");
helptext.Add(" -oc, --output-cmp Output in CMP format"); helptext.Add(" -oc, --output-cmp Output in CMP format");
helptext.Add(" -ocsv, --output-csv Output in CSV format");
helptext.Add(" -pre=, --prefix= Set prefix for all lines");
helptext.Add(" -post=, --postfix= Set postfix for all lines");
helptext.Add(" -q, --quotes Put double-quotes around each item");
helptext.Add(" -od, --output-dc Output in DOSCenter format"); helptext.Add(" -od, --output-dc Output in DOSCenter format");
helptext.Add(" -om, --output-miss Output in Missfile format"); helptext.Add(" -om, --output-miss Output in Missfile format");
helptext.Add(" -r, --roms Output roms to miss instead of sets"); helptext.Add(" -r, --roms Output roms to miss instead of sets");
@@ -182,6 +190,10 @@ namespace SabreTools.Helper
helptext.Add(" -osha1, --output-sha1 Output in SHA-1 format"); helptext.Add(" -osha1, --output-sha1 Output in SHA-1 format");
helptext.Add(" -gp, --game-prefix Add game name as a prefix"); helptext.Add(" -gp, --game-prefix Add game name as a prefix");
helptext.Add(" -osl, --output-sl Output in Softwarelist format"); helptext.Add(" -osl, --output-sl Output in Softwarelist format");
helptext.Add(" -otsv, --output-tsv Output in TSV format");
helptext.Add(" -pre=, --prefix= Set prefix for all lines");
helptext.Add(" -post=, --postfix= Set postfix for all lines");
helptext.Add(" -q, --quotes Put double-quotes around each item");
helptext.Add(" -ox, --output-xml Output in Logiqx XML format"); helptext.Add(" -ox, --output-xml Output in Logiqx XML format");
helptext.Add(" -f=, --filename= Set a new filename"); helptext.Add(" -f=, --filename= Set a new filename");
helptext.Add(" -n=, --name= Set a new internal name"); helptext.Add(" -n=, --name= Set a new internal name");

View File

@@ -25,17 +25,21 @@ namespace SabreTools.Helper
[Flags] [Flags]
public enum OutputFormat public enum OutputFormat
{ {
Logiqx = 0x001, Logiqx = 0x0001,
ClrMamePro = 0x002, ClrMamePro = 0x0002,
RomCenter = 0x004, RomCenter = 0x0004,
DOSCenter = 0x008, DOSCenter = 0x0008,
MissFile = 0x010, MissFile = 0x0010,
SabreDat = 0x020, SabreDat = 0x0020,
RedumpMD5 = 0x040, RedumpMD5 = 0x0040,
RedumpSHA1 = 0x080, RedumpSHA1 = 0x0080,
RedumpSFV = 0x100, RedumpSFV = 0x0100,
SoftwareList = 0x200, SoftwareList = 0x0200,
OfflineList = 0x400, OfflineList = 0x0400,
TSV = 0x0800,
CSV = 0x1000,
ALL = 0xFFFF,
} }
/// <summary> /// <summary>

View File

@@ -48,7 +48,6 @@ namespace SabreTools.Helper
private bool _remExt; private bool _remExt;
private bool _gameName; private bool _gameName;
private bool _romba; private bool _romba;
private bool? _xsv; // true for tab-deliminated output, false for comma-deliminated output
// Statistical data related to the DAT // Statistical data related to the DAT
private long _romCount; private long _romCount;
@@ -227,11 +226,6 @@ namespace SabreTools.Helper
get { return _romba; } get { return _romba; }
set { _romba = value; } set { _romba = value; }
} }
public bool? XSV // true for tab-deliminated output, false for comma-deliminated output
{
get { return _xsv; }
set { _xsv = value; }
}
// Statistical data related to the DAT // Statistical data related to the DAT
public long RomCount public long RomCount
@@ -362,10 +356,9 @@ namespace SabreTools.Helper
/// <param name="remExt">Remove all extensions</param> /// <param name="remExt">Remove all extensions</param>
/// <param name="gameName">Add the dat name as a directory prefix</param> /// <param name="gameName">Add the dat name as a directory prefix</param>
/// <param name="romba">Output files in romba format</param> /// <param name="romba">Output files in romba format</param>
/// <param name="xsv">True to output files in TSV format, false to output files in CSV format, null otherwise</param>
public DatFile(string fileName, string name, string description, OutputFormat outputFormat, bool mergeRoms, public DatFile(string fileName, string name, string description, OutputFormat outputFormat, bool mergeRoms,
SortedDictionary<string, List<DatItem>> files, bool useGame, string prefix, string postfix, bool quotes, SortedDictionary<string, List<DatItem>> files, bool useGame, string prefix, string postfix, bool quotes,
string repExt, string addExt, bool remExt, bool gameName, bool romba, bool? xsv) string repExt, string addExt, bool remExt, bool gameName, bool romba)
{ {
_fileName = fileName; _fileName = fileName;
_name = name; _name = name;
@@ -383,7 +376,6 @@ namespace SabreTools.Helper
_remExt = remExt; _remExt = remExt;
_gameName = gameName; _gameName = gameName;
_romba = romba; _romba = romba;
_xsv = xsv;
_romCount = 0; _romCount = 0;
_diskCount = 0; _diskCount = 0;
@@ -514,7 +506,6 @@ namespace SabreTools.Helper
RemExt = this.RemExt, RemExt = this.RemExt,
GameName = this.GameName, GameName = this.GameName,
Romba = this.Romba, Romba = this.Romba,
XSV = this.XSV,
RomCount = this.RomCount, RomCount = this.RomCount,
DiskCount = this.DiskCount, DiskCount = this.DiskCount,
TotalSize = this.TotalSize, TotalSize = this.TotalSize,
@@ -560,7 +551,6 @@ namespace SabreTools.Helper
RemExt = this.RemExt, RemExt = this.RemExt,
GameName = this.GameName, GameName = this.GameName,
Romba = this.Romba, Romba = this.Romba,
XSV = this.XSV,
}; };
} }
@@ -688,7 +678,8 @@ namespace SabreTools.Helper
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\""); logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
innerDatdata.Parse(inputFileName, 0, 0, gamename, romname, innerDatdata.Parse(inputFileName, 0, 0, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single,
root, logger, true, clean, softlist, keepext: (innerDatdata.XSV != null)); root, logger, true, clean, softlist,
keepext: ((innerDatdata.OutputFormat & OutputFormat.TSV) != 0 || (innerDatdata.OutputFormat & OutputFormat.CSV) != 0));
// If we have roms, output them // If we have roms, output them
if (innerDatdata.Files.Count != 0) if (innerDatdata.Files.Count != 0)
@@ -708,7 +699,8 @@ namespace SabreTools.Helper
DatFile innerDatdata = (DatFile)Clone(); DatFile innerDatdata = (DatFile)Clone();
innerDatdata.Files = null; innerDatdata.Files = null;
innerDatdata.Parse(file, 0, 0, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, innerDatdata.Parse(file, 0, 0, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus,
trim, single, root, logger, true, clean, keepext: (XSV != null)); trim, single, root, logger, true, clean,
keepext: ((innerDatdata.OutputFormat & OutputFormat.TSV) != 0 || (innerDatdata.OutputFormat & OutputFormat.CSV) != 0));
// If we have roms, output them // If we have roms, output them
if (innerDatdata.Files != null && innerDatdata.Files.Count != 0) if (innerDatdata.Files != null && innerDatdata.Files.Count != 0)
@@ -3513,7 +3505,10 @@ namespace SabreTools.Helper
logger.Verbose("Empty folder found: " + rom.MachineName); logger.Verbose("Empty folder found: " + rom.MachineName);
// If we're in a mode that doesn't allow for actual empty folders, add the blank info // If we're in a mode that doesn't allow for actual empty folders, add the blank info
if (outputFormat != OutputFormat.SabreDat && outputFormat != OutputFormat.MissFile) if (outputFormat != OutputFormat.CSV
&& outputFormat != OutputFormat.MissFile
&& outputFormat != OutputFormat.SabreDat
&& outputFormat != OutputFormat.TSV)
{ {
rom.Name = (rom.Name == "null" ? "-" : rom.Name); rom.Name = (rom.Name == "null" ? "-" : rom.Name);
((Rom)rom).Size = Constants.SizeZero; ((Rom)rom).Size = Constants.SizeZero;
@@ -3589,6 +3584,10 @@ namespace SabreTools.Helper
(ForceMerging == ForceMerging.Split ? "\tforcemerging split\n" : "") + (ForceMerging == ForceMerging.Split ? "\tforcemerging split\n" : "") +
")\n"; ")\n";
break; break;
case OutputFormat.CSV:
header = "\"File Name\",\"Internal Name\",\"Description\",\"Game Name\",\"Game Description\",\"Type\",\"" +
"Rom Name\",\"Disk Name\",\"Size\",\"CRC\",\"MD5\",\"SHA1\",\"Nodump\"\n";
break;
case OutputFormat.DOSCenter: case OutputFormat.DOSCenter:
header = "DOSCenter (\n" + header = "DOSCenter (\n" +
"Name: " + Name + "\"\n" + "Name: " + Name + "\"\n" +
@@ -3630,17 +3629,9 @@ namespace SabreTools.Helper
: "") + : "") +
"\t</header>\n"; "\t</header>\n";
break; break;
case OutputFormat.MissFile: case OutputFormat.TSV:
if (XSV == true) header = "\"File Name\"\t\"Internal Name\"\t\"Description\"\t\"Game Name\"\t\"Game Description\"\t\"Type\"\t\"" +
{
header = "\"File Name\"\t\"Internal Name\"\t\"Description\"\t\"Game Name\"\t\"Game Description\"\t\"Type\"\t\"" +
"Rom Name\"\t\"Disk Name\"\t\"Size\"\t\"CRC\"\t\"MD5\"\t\"SHA1\"\t\"Nodump\"\n"; "Rom Name\"\t\"Disk Name\"\t\"Size\"\t\"CRC\"\t\"MD5\"\t\"SHA1\"\t\"Nodump\"\n";
}
else if (XSV == false)
{
header = "\"File Name\",\"Internal Name\",\"Description\",\"Game Name\",\"Game Description\",\"Type\",\"" +
"Rom Name\",\"Disk Name\",\"Size\",\"CRC\",\"MD5\",\"SHA1\",\"Nodump\"\n";
}
break; break;
case OutputFormat.OfflineList: case OutputFormat.OfflineList:
header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
@@ -3957,7 +3948,7 @@ namespace SabreTools.Helper
try try
{ {
string state = ""; string state = "", name = "", pre = "", post = "";
switch (outputFormat) switch (outputFormat)
{ {
case OutputFormat.ClrMamePro: case OutputFormat.ClrMamePro:
@@ -4008,6 +3999,84 @@ namespace SabreTools.Helper
break; break;
} }
break;
case OutputFormat.CSV:
// CSV should only output Rom and Disk
if (rom.Type != ItemType.Disk && rom.Type != ItemType.Rom)
{
return true;
}
pre = Prefix + (Quotes ? "\"" : "");
post = (Quotes ? "\"" : "") + Postfix;
if (rom.Type == ItemType.Rom)
{
// Check for special strings in prefix and postfix
pre = pre
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%crc%", ((Rom)rom).CRC)
.Replace("%md5%", ((Rom)rom).MD5)
.Replace("%sha1%", ((Rom)rom).SHA1)
.Replace("%size%", ((Rom)rom).Size.ToString());
post = post
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%crc%", ((Rom)rom).CRC)
.Replace("%md5%", ((Rom)rom).MD5)
.Replace("%sha1%", ((Rom)rom).SHA1)
.Replace("%size%", ((Rom)rom).Size.ToString());
}
else if (rom.Type == ItemType.Disk)
{
// Check for special strings in prefix and postfix
pre = pre
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%md5%", ((Disk)rom).MD5)
.Replace("%sha1%", ((Disk)rom).SHA1);
post = post
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%md5%", ((Disk)rom).MD5)
.Replace("%sha1%", ((Disk)rom).SHA1);
}
if (rom.Type == ItemType.Rom)
{
string inline = "\"" + FileName + "\""
+ ",\"" + Name + "\""
+ ",\"" + Description + "\""
+ ",\"" + rom.MachineName + "\""
+ ",\"" + rom.MachineDescription + "\""
+ "," + "\"rom\""
+ ",\"" + rom.Name + "\""
+ "," + "\"\""
+ ",\"" + ((Rom)rom).Size + "\""
+ ",\"" + ((Rom)rom).CRC + "\""
+ ",\"" + ((Rom)rom).MD5 + "\""
+ ",\"" + ((Rom)rom).SHA1 + "\""
+ "," + (((Rom)rom).ItemStatus != ItemStatus.None ? "\"" + ((Rom)rom).ItemStatus.ToString() + "\"" : "\"\"");
state += pre + inline + post + "\n";
}
else if (rom.Type == ItemType.Disk)
{
string inline = "\"" + FileName + "\""
+ ",\"" + Name + "\""
+ ",\"" + Description + "\""
+ ",\"" + rom.MachineName + "\""
+ ",\"" + rom.MachineDescription + "\""
+ "," + "\"disk\""
+ "," + "\"\""
+ ",\"" + rom.Name + "\""
+ "," + "\"\""
+ "," + "\"\""
+ ",\"" + ((Disk)rom).MD5 + "\""
+ ",\"" + ((Disk)rom).SHA1 + "\""
+ "," + (((Disk)rom).ItemStatus != ItemStatus.None ? "\"" + ((Disk)rom).ItemStatus.ToString() + "\"" : "\"\"");
state += pre + inline + post + "\n";
}
break; break;
case OutputFormat.DOSCenter: case OutputFormat.DOSCenter:
switch (rom.Type) switch (rom.Type)
@@ -4078,13 +4147,13 @@ namespace SabreTools.Helper
break; break;
case OutputFormat.MissFile: case OutputFormat.MissFile:
// Missfile should only output Rom and Disk // Missfile should only output Rom and Disk
if (rom.Type != ItemType.Disk && rom.Type != ItemType.Disk) if (rom.Type != ItemType.Disk && rom.Type != ItemType.Rom)
{ {
return true; return true;
} }
string pre = Prefix + (Quotes ? "\"" : ""); pre = Prefix + (Quotes ? "\"" : "");
string post = (Quotes ? "\"" : "") + Postfix; post = (Quotes ? "\"" : "") + Postfix;
if (rom.Type == ItemType.Rom) if (rom.Type == ItemType.Rom)
{ {
@@ -4127,7 +4196,7 @@ namespace SabreTools.Helper
// We can only write out if there's a SHA-1 // We can only write out if there's a SHA-1
if (((Rom)rom).SHA1 != "") if (((Rom)rom).SHA1 != "")
{ {
string name = ((Rom)rom).SHA1.Substring(0, 2) name = ((Rom)rom).SHA1.Substring(0, 2)
+ "/" + ((Rom)rom).SHA1.Substring(2, 2) + "/" + ((Rom)rom).SHA1.Substring(2, 2)
+ "/" + ((Rom)rom).SHA1.Substring(4, 2) + "/" + ((Rom)rom).SHA1.Substring(4, 2)
+ "/" + ((Rom)rom).SHA1.Substring(6, 2) + "/" + ((Rom)rom).SHA1.Substring(6, 2)
@@ -4140,7 +4209,7 @@ namespace SabreTools.Helper
// We can only write out if there's a SHA-1 // We can only write out if there's a SHA-1
if (((Disk)rom).SHA1 != "") if (((Disk)rom).SHA1 != "")
{ {
string name = ((Disk)rom).SHA1.Substring(0, 2) name = ((Disk)rom).SHA1.Substring(0, 2)
+ "/" + ((Disk)rom).SHA1.Substring(2, 2) + "/" + ((Disk)rom).SHA1.Substring(2, 2)
+ "/" + ((Disk)rom).SHA1.Substring(4, 2) + "/" + ((Disk)rom).SHA1.Substring(4, 2)
+ "/" + ((Disk)rom).SHA1.Substring(6, 2) + "/" + ((Disk)rom).SHA1.Substring(6, 2)
@@ -4149,79 +4218,37 @@ namespace SabreTools.Helper
} }
} }
} }
// If we're in TSV/CSV mode, similarly the state is consistent
else if (XSV != null)
{
string separator = (XSV == true ? "\t" : ",");
if (rom.Type == ItemType.Rom)
{
string inline = "\"" + FileName + "\""
+ separator + "\"" + Name + "\""
+ separator + "\"" + Description + "\""
+ separator + "\"" + rom.MachineName + "\""
+ separator + "\"" + rom.MachineDescription + "\""
+ separator + "\"rom\""
+ separator + "\"" + rom.Name + "\""
+ separator + "\"\""
+ separator + "\"" + ((Rom)rom).Size + "\""
+ separator + "\"" + ((Rom)rom).CRC + "\""
+ separator + "\"" + ((Rom)rom).MD5 + "\""
+ separator + "\"" + ((Rom)rom).SHA1 + "\""
+ separator + (((Rom)rom).ItemStatus != ItemStatus.None ? "\"" + ((Rom)rom).ItemStatus.ToString() + "\"" : "\"\"");
state += pre + inline + post + "\n";
}
else if (rom.Type == ItemType.Disk)
{
string inline = "\"" + FileName + "\""
+ separator + "\"" + Name + "\""
+ separator + "\"" + Description + "\""
+ separator + "\"" + rom.MachineName + "\""
+ separator + "\"" + rom.MachineDescription + "\""
+ separator + "\"disk\""
+ separator + "\"\""
+ separator + "\"" + rom.Name + "\""
+ separator + "\"\""
+ separator + "\"\""
+ separator + "\"" + ((Disk)rom).MD5 + "\""
+ separator + "\"" + ((Disk)rom).SHA1 + "\""
+ separator + (((Disk)rom).ItemStatus != ItemStatus.None ? "\"" + ((Disk)rom).ItemStatus.ToString() + "\"" : "\"\"");
state += pre + inline + post + "\n";
}
}
// Otherwise, use any flags // Otherwise, use any flags
else name = (UseGame ? rom.MachineName : rom.Name);
if (RepExt != "" || RemExt)
{ {
string name = (UseGame ? rom.MachineName : rom.Name); if (RemExt)
if (RepExt != "" || RemExt)
{ {
if (RemExt) RepExt = "";
{
RepExt = "";
}
string dir = Path.GetDirectoryName(name);
dir = (dir.StartsWith(Path.DirectorySeparatorChar.ToString()) ? dir.Remove(0, 1) : dir);
name = Path.Combine(dir, Path.GetFileNameWithoutExtension(name) + RepExt);
}
if (AddExt != "")
{
name += AddExt;
}
if (!UseGame && GameName)
{
name = Path.Combine(rom.MachineName, name);
} }
if (UseGame && rom.MachineName != lastgame) string dir = Path.GetDirectoryName(name);
{ dir = (dir.StartsWith(Path.DirectorySeparatorChar.ToString()) ? dir.Remove(0, 1) : dir);
state += pre + name + post + "\n"; name = Path.Combine(dir, Path.GetFileNameWithoutExtension(name) + RepExt);
lastgame = rom.MachineName; }
} if (AddExt != "")
else if (!UseGame) {
{ name += AddExt;
state += pre + name + post + "\n"; }
} if (!UseGame && GameName)
{
name = Path.Combine(rom.MachineName, name);
}
if (UseGame && rom.MachineName != lastgame)
{
state += pre + name + post + "\n";
lastgame = rom.MachineName;
}
else if (!UseGame)
{
state += pre + name + post + "\n";
} }
break; break;
case OutputFormat.OfflineList: case OutputFormat.OfflineList:
@@ -4452,6 +4479,84 @@ namespace SabreTools.Helper
break; break;
} }
break; break;
case OutputFormat.TSV:
// TSV should only output Rom and Disk
if (rom.Type != ItemType.Disk && rom.Type != ItemType.Rom)
{
return true;
}
pre = Prefix + (Quotes ? "\"" : "");
post = (Quotes ? "\"" : "") + Postfix;
if (rom.Type == ItemType.Rom)
{
// Check for special strings in prefix and postfix
pre = pre
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%crc%", ((Rom)rom).CRC)
.Replace("%md5%", ((Rom)rom).MD5)
.Replace("%sha1%", ((Rom)rom).SHA1)
.Replace("%size%", ((Rom)rom).Size.ToString());
post = post
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%crc%", ((Rom)rom).CRC)
.Replace("%md5%", ((Rom)rom).MD5)
.Replace("%sha1%", ((Rom)rom).SHA1)
.Replace("%size%", ((Rom)rom).Size.ToString());
}
else if (rom.Type == ItemType.Disk)
{
// Check for special strings in prefix and postfix
pre = pre
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%md5%", ((Disk)rom).MD5)
.Replace("%sha1%", ((Disk)rom).SHA1);
post = post
.Replace("%game%", rom.MachineName)
.Replace("%name%", rom.Name)
.Replace("%md5%", ((Disk)rom).MD5)
.Replace("%sha1%", ((Disk)rom).SHA1);
}
if (rom.Type == ItemType.Rom)
{
string inline = "\"" + FileName + "\""
+ "\t\"" + Name + "\""
+ "\t\"" + Description + "\""
+ "\t\"" + rom.MachineName + "\""
+ "\t\"" + rom.MachineDescription + "\""
+ "\t" + "\"rom\""
+ "\t\"" + rom.Name + "\""
+ "\t" + "\"\""
+ "\t\"" + ((Rom)rom).Size + "\""
+ "\t\"" + ((Rom)rom).CRC + "\""
+ "\t\"" + ((Rom)rom).MD5 + "\""
+ "\t\"" + ((Rom)rom).SHA1 + "\""
+ "\t" + (((Rom)rom).ItemStatus != ItemStatus.None ? "\"" + ((Rom)rom).ItemStatus.ToString() + "\"" : "\"\"");
state += pre + inline + post + "\n";
}
else if (rom.Type == ItemType.Disk)
{
string inline = "\"" + FileName + "\""
+ "\t\"" + Name + "\""
+ "\t\"" + Description + "\""
+ "\t\"" + rom.MachineName + "\""
+ "\t\"" + rom.MachineDescription + "\""
+ "\t" + "\"disk\""
+ "\t" + "\"\""
+ "\t\"" + rom.Name + "\""
+ "\t" + "\"\""
+ "\t" + "\"\""
+ "\t\"" + ((Disk)rom).MD5 + "\""
+ "\t\"" + ((Disk)rom).SHA1 + "\""
+ "\t" + (((Disk)rom).ItemStatus != ItemStatus.None ? "\"" + ((Disk)rom).ItemStatus.ToString() + "\"" : "\"\"");
state += pre + inline + post + "\n";
}
break;
} }
sw.Write(state); sw.Write(state);

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Web;
namespace SabreTools.Helper namespace SabreTools.Helper
{ {
@@ -808,11 +809,11 @@ namespace SabreTools.Helper
{ {
if ((x.Type == ItemType.Rom || x.Type == ItemType.Disk) && (y.Type == ItemType.Rom || y.Type == ItemType.Disk)) if ((x.Type == ItemType.Rom || x.Type == ItemType.Disk) && (y.Type == ItemType.Rom || y.Type == ItemType.Disk))
{ {
if (Path.GetDirectoryName(x.Name) == Path.GetDirectoryName(y.Name)) if (Path.GetDirectoryName(HttpUtility.HtmlEncode(x.Name)) == Path.GetDirectoryName(HttpUtility.HtmlEncode(y.Name)))
{ {
return nc.Compare(Path.GetFileName(x.Name), Path.GetFileName(y.Name)); return nc.Compare(Path.GetFileName(HttpUtility.HtmlEncode(x.Name)), Path.GetFileName(HttpUtility.HtmlEncode(y.Name)));
} }
return nc.Compare(Path.GetDirectoryName(x.Name), Path.GetDirectoryName(y.Name)); return nc.Compare(Path.GetDirectoryName(HttpUtility.HtmlEncode(x.Name)), Path.GetDirectoryName(HttpUtility.HtmlEncode(y.Name)));
} }
else if ((x.Type == ItemType.Rom || x.Type == ItemType.Disk) && (y.Type != ItemType.Rom && y.Type != ItemType.Disk)) else if ((x.Type == ItemType.Rom || x.Type == ItemType.Disk) && (y.Type != ItemType.Rom && y.Type != ItemType.Disk))
{ {

View File

@@ -163,8 +163,15 @@ Options:
files themselves. This is good for uncompressed sets that include archives that files themselves. This is good for uncompressed sets that include archives that
should be read as-is. should be read as-is.
-oa, --output-all Output in all available formats
Add outputting the created DAT in all available formats. See specific formats for
additional flags that may be used.
-oc, --output-cmp Output in CMP format -oc, --output-cmp Output in CMP format
Add outputting the created DAT to clrmamepro format Add outputting the created DAT to clrmamepro format
-ocsv, --output-csv Output in Comma-Separated Value format
Add outputting the created DAT to standardized CSV format
-od, --output-dc Output in DOSCenter format -od, --output-dc Output in DOSCenter format
Add outputting the created DAT to DOSCenter format Add outputting the created DAT to DOSCenter format
@@ -193,6 +200,9 @@ Options:
-osl, --output-sl Output in Software List format -osl, --output-sl Output in Software List format
Add outputting the created DAT to Software List XML format Add outputting the created DAT to Software List XML format
-otsv, --output-tsv Output in Tab-Separated Value format
Add outputting the created DAT to standardized TSV format
-ox, -output-xml Output in Logiqx XML format (default) -ox, -output-xml Output in Logiqx XML format (default)
Add outputting the created DAT to Logiqx XML format Add outputting the created DAT to Logiqx XML format
@@ -374,8 +384,32 @@ Options:
to a DAT, or set of DATs. This is also a combination of many different programs to a DAT, or set of DATs. This is also a combination of many different programs
that performed DAT manipulation that work better together. that performed DAT manipulation that work better together.
-oa, --output-all Output in all available formats
Add outputting the created DAT in all available formats. See specific formats for
additional flags that may be used.
-oc, --output-cmp Output in CMP format -oc, --output-cmp Output in CMP format
Add outputting the created DAT to clrmamepro format Add outputting the created DAT to clrmamepro format
-ocsv, --output-csv Output in Comma-Separated Value format
Add outputting the created DAT to standardized CSV format
-pre=, --prefix= Set prefix for all lines
Set a generic prefix to be prepended to all outputted lines
-post=, --postfix= Set postfix for all lines
Set a generic postfix to be appended to all outputted lines
Both prefix and postfix can use one of the following special strings:
- %game% - Replaced with the Game/Machine name
- %name% - Replaced with the Rom name
- %crc% - Replaced with the CRC
- %md5% - Replaced with the MD5
- %sha1% - Replaced with the SHA-1
- %size% - Replaced with the size
-q, --quotes Put double-quotes around each item
This quotes only the item and not the prefix and postfix
-od, --output-dc Output in DOSCenter format -od, --output-dc Output in DOSCenter format
Add outputting the created DAT to DOSCenter format Add outputting the created DAT to DOSCenter format
@@ -421,12 +455,6 @@ Options:
Instead of outputting the game or rom name, output the SHA-1 of the files Instead of outputting the game or rom name, output the SHA-1 of the files
instead. This requires the source DAT to have SHA-1 hashes. instead. This requires the source DAT to have SHA-1 hashes.
-tsv, --tsv Output in Tab-Separated Value format
Output all rom information in standardized TSV format
-csv, --csv Output in Comma-Separated Value format
Output all rom information in standardized CSV format
-omd5, --output-md5 Output in MD5 format -omd5, --output-md5 Output in MD5 format
Add outputting the created DAT to MD5 format Add outputting the created DAT to MD5 format
@@ -457,6 +485,26 @@ Options:
-osl, --output-sl Output in Software List format -osl, --output-sl Output in Software List format
Add outputting the created DAT to Software List XML format Add outputting the created DAT to Software List XML format
-otsv, --output-tsv Output in Tab-Separated Value format
Add outputting the created DAT to standardized TSV format
-pre=, --prefix= Set prefix for all lines
Set a generic prefix to be prepended to all outputted lines
-post=, --postfix= Set postfix for all lines
Set a generic postfix to be appended to all outputted lines
Both prefix and postfix can use one of the following special strings:
- %game% - Replaced with the Game/Machine name
- %name% - Replaced with the Rom name
- %crc% - Replaced with the CRC
- %md5% - Replaced with the MD5
- %sha1% - Replaced with the SHA-1
- %size% - Replaced with the size
-q, --quotes Put double-quotes around each item
This quotes only the item and not the prefix and postfix
-ox, -output-xml Output in Logiqx XML format (default) -ox, -output-xml Output in Logiqx XML format (default)
Add outputting the created DAT to Logiqx XML format Add outputting the created DAT to Logiqx XML format

View File

@@ -173,6 +173,12 @@ namespace SabreTools.Helper
outfileNames.Add(OutputFormat.ClrMamePro, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite)); outfileNames.Add(OutputFormat.ClrMamePro, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite));
}; };
// CSV
if ((datdata.OutputFormat & OutputFormat.CSV) != 0)
{
outfileNames.Add(OutputFormat.CSV, CreateOutfileNamesHelper(outDir, ".csv", datdata, overwrite));
};
// DOSCenter // DOSCenter
if ((datdata.OutputFormat & OutputFormat.DOSCenter) != 0 if ((datdata.OutputFormat & OutputFormat.DOSCenter) != 0
&& (datdata.OutputFormat & OutputFormat.ClrMamePro) == 0 && (datdata.OutputFormat & OutputFormat.ClrMamePro) == 0
@@ -187,6 +193,12 @@ namespace SabreTools.Helper
outfileNames.Add(OutputFormat.DOSCenter, CreateOutfileNamesHelper(outDir, ".dc.dat", datdata, overwrite)); outfileNames.Add(OutputFormat.DOSCenter, CreateOutfileNamesHelper(outDir, ".dc.dat", datdata, overwrite));
}; };
// Logiqx XML
if ((datdata.OutputFormat & OutputFormat.Logiqx) != 0)
{
outfileNames.Add(OutputFormat.Logiqx, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
};
// Missfile // Missfile
if ((datdata.OutputFormat & OutputFormat.MissFile) != 0) if ((datdata.OutputFormat & OutputFormat.MissFile) != 0)
{ {
@@ -263,10 +275,10 @@ namespace SabreTools.Helper
outfileNames.Add(OutputFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".sl.xml", datdata, overwrite)); outfileNames.Add(OutputFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".sl.xml", datdata, overwrite));
} }
// Logiqx XML // TSV
if ((datdata.OutputFormat & OutputFormat.Logiqx) != 0) if ((datdata.OutputFormat & OutputFormat.TSV) != 0)
{ {
outfileNames.Add(OutputFormat.Logiqx, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite)); outfileNames.Add(OutputFormat.TSV, CreateOutfileNamesHelper(outDir, ".tsv", datdata, overwrite));
}; };
return outfileNames; return outfileNames;

View File

@@ -379,7 +379,6 @@ namespace SabreTools
/// <param name="remext">Remove all extensions</param> /// <param name="remext">Remove all extensions</param>
/// <param name="datprefix">Add the dat name as a directory prefix</param> /// <param name="datprefix">Add the dat name as a directory prefix</param>
/// <param name="romba">Output files in romba format</param> /// <param name="romba">Output files in romba format</param>
/// <param name="tsv">True to output files in TSV format, false to output files in CSV format, null otherwise</param>
/// /* Merging and Diffing info */ /// /* Merging and Diffing info */
/// <param name="merge">True if input files should be merged into a single file, false otherwise</param> /// <param name="merge">True if input files should be merged into a single file, false otherwise</param>
/// <param name="diffMode">Non-zero flag for diffing mode, zero otherwise</param> /// <param name="diffMode">Non-zero flag for diffing mode, zero otherwise</param>
@@ -440,7 +439,6 @@ namespace SabreTools
bool remext, bool remext,
bool datprefix, bool datprefix,
bool romba, bool romba,
bool? tsv,
/* Merging and Diffing info */ /* Merging and Diffing info */
bool merge, bool merge,
@@ -615,7 +613,6 @@ namespace SabreTools
RemExt = remext, RemExt = remext,
GameName = datprefix, GameName = datprefix,
Romba = romba, Romba = romba,
XSV = tsv,
}; };
userInputDat.Update(inputs, outDir, merge, diffMode, inplace, skip, bare, clean, softlist, userInputDat.Update(inputs, outDir, merge, diffMode, inplace, skip, bare, clean, softlist,

View File

@@ -86,7 +86,6 @@ namespace SabreTools
trim = false, trim = false,
skip = false, skip = false,
usegame = true; usegame = true;
bool? tsv = null;
DiffMode diffMode = 0x0; DiffMode diffMode = 0x0;
int maxParallelism = 4; int maxParallelism = 4;
long sgt = -1, long sgt = -1,
@@ -174,7 +173,6 @@ namespace SabreTools
break; break;
case "-csv": case "-csv":
case "--csv": case "--csv":
tsv = false;
statOutputFormat = StatOutputFormat.CSV; statOutputFormat = StatOutputFormat.CSV;
break; break;
case "-clean": case "-clean":
@@ -254,10 +252,18 @@ namespace SabreTools
case "--noSHA1": case "--noSHA1":
noSHA1 = true; noSHA1 = true;
break; break;
case "-oa":
case "--output-all":
outputFormat |= OutputFormat.ALL;
break;
case "-oc": case "-oc":
case "--output-cmp": case "--output-cmp":
outputFormat |= OutputFormat.ClrMamePro; outputFormat |= OutputFormat.ClrMamePro;
break; break;
case "-ocsv":
case "--output-csv":
outputFormat |= OutputFormat.CSV;
break;
case "-od": case "-od":
case "--output-dc": case "--output-dc":
outputFormat |= OutputFormat.DOSCenter; outputFormat |= OutputFormat.DOSCenter;
@@ -294,6 +300,10 @@ namespace SabreTools
case "--output-sl": case "--output-sl":
outputFormat |= OutputFormat.SoftwareList; outputFormat |= OutputFormat.SoftwareList;
break; break;
case "-otsv":
case "--output-tsv":
outputFormat |= OutputFormat.TSV;
break;
case "-ox": case "-ox":
case "--output-xml": case "--output-xml":
outputFormat |= OutputFormat.Logiqx; outputFormat |= OutputFormat.Logiqx;
@@ -352,7 +362,6 @@ namespace SabreTools
break; break;
case "-tsv": case "-tsv":
case "--tsv": case "--tsv":
tsv = true;
statOutputFormat = StatOutputFormat.TSV; statOutputFormat = StatOutputFormat.TSV;
break; break;
case "-ud": case "-ud":
@@ -621,11 +630,11 @@ namespace SabreTools
} }
// Convert, update, merge, diff, and filter a DAT or folder of DATs // Convert, update, merge, diff, and filter a DAT or folder of DATs
else if (update || tsv != null || outputFormat != 0 || merge || diffMode != 0) else if (update || outputFormat != 0 || merge || diffMode != 0)
{ {
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header, InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
superdat, forcemerge, forcend, forcepack, excludeOf, outputFormat, usegame, prefix, superdat, forcemerge, forcend, forcepack, excludeOf, outputFormat, usegame, prefix,
postfix, quotes, repext, addext, remext, datPrefix, romba, tsv, merge, diffMode, inplace, skip, removeDateFromAutomaticName, gamename, romname, postfix, quotes, repext, addext, remext, datPrefix, romba, merge, diffMode, inplace, skip, removeDateFromAutomaticName, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, status, trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism); romtype, sgt, slt, seq, crc, md5, sha1, status, trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism);
} }