mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] TSV and CSV are top level now
This commit is contained in:
@@ -111,7 +111,9 @@ namespace SabreTools.Helper
|
||||
helptext.Add(" -b, --bare Don't include date in file name");
|
||||
helptext.Add(" -u, --unzip Force unzipping in created DAT");
|
||||
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(" -ocsv, --output-csv Output in CSV format");
|
||||
helptext.Add(" -od, --output-dc Output in DOSCenter format");
|
||||
helptext.Add(" -om, --output-miss Output in Missfile 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(" -osha1, --output-sha1 Output in SHA-1 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(" -gz, --gz-files Allow reading of GZIP files as archives");
|
||||
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(" -out= Output directory");
|
||||
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(" -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(" -om, --output-miss Output in Missfile format");
|
||||
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(" -gp, --game-prefix Add game name as a prefix");
|
||||
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(" -f=, --filename= Set a new filename");
|
||||
helptext.Add(" -n=, --name= Set a new internal name");
|
||||
|
||||
@@ -25,17 +25,21 @@ namespace SabreTools.Helper
|
||||
[Flags]
|
||||
public enum OutputFormat
|
||||
{
|
||||
Logiqx = 0x001,
|
||||
ClrMamePro = 0x002,
|
||||
RomCenter = 0x004,
|
||||
DOSCenter = 0x008,
|
||||
MissFile = 0x010,
|
||||
SabreDat = 0x020,
|
||||
RedumpMD5 = 0x040,
|
||||
RedumpSHA1 = 0x080,
|
||||
RedumpSFV = 0x100,
|
||||
SoftwareList = 0x200,
|
||||
OfflineList = 0x400,
|
||||
Logiqx = 0x0001,
|
||||
ClrMamePro = 0x0002,
|
||||
RomCenter = 0x0004,
|
||||
DOSCenter = 0x0008,
|
||||
MissFile = 0x0010,
|
||||
SabreDat = 0x0020,
|
||||
RedumpMD5 = 0x0040,
|
||||
RedumpSHA1 = 0x0080,
|
||||
RedumpSFV = 0x0100,
|
||||
SoftwareList = 0x0200,
|
||||
OfflineList = 0x0400,
|
||||
TSV = 0x0800,
|
||||
CSV = 0x1000,
|
||||
|
||||
ALL = 0xFFFF,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -48,7 +48,6 @@ namespace SabreTools.Helper
|
||||
private bool _remExt;
|
||||
private bool _gameName;
|
||||
private bool _romba;
|
||||
private bool? _xsv; // true for tab-deliminated output, false for comma-deliminated output
|
||||
|
||||
// Statistical data related to the DAT
|
||||
private long _romCount;
|
||||
@@ -227,11 +226,6 @@ namespace SabreTools.Helper
|
||||
get { return _romba; }
|
||||
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
|
||||
public long RomCount
|
||||
@@ -362,10 +356,9 @@ namespace SabreTools.Helper
|
||||
/// <param name="remExt">Remove all extensions</param>
|
||||
/// <param name="gameName">Add the dat name as a directory prefix</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,
|
||||
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;
|
||||
_name = name;
|
||||
@@ -383,7 +376,6 @@ namespace SabreTools.Helper
|
||||
_remExt = remExt;
|
||||
_gameName = gameName;
|
||||
_romba = romba;
|
||||
_xsv = xsv;
|
||||
|
||||
_romCount = 0;
|
||||
_diskCount = 0;
|
||||
@@ -514,7 +506,6 @@ namespace SabreTools.Helper
|
||||
RemExt = this.RemExt,
|
||||
GameName = this.GameName,
|
||||
Romba = this.Romba,
|
||||
XSV = this.XSV,
|
||||
RomCount = this.RomCount,
|
||||
DiskCount = this.DiskCount,
|
||||
TotalSize = this.TotalSize,
|
||||
@@ -560,7 +551,6 @@ namespace SabreTools.Helper
|
||||
RemExt = this.RemExt,
|
||||
GameName = this.GameName,
|
||||
Romba = this.Romba,
|
||||
XSV = this.XSV,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -688,7 +678,8 @@ namespace SabreTools.Helper
|
||||
logger.User("Processing \"" + Path.GetFileName(inputFileName) + "\"");
|
||||
innerDatdata.Parse(inputFileName, 0, 0, gamename, romname,
|
||||
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 (innerDatdata.Files.Count != 0)
|
||||
@@ -708,7 +699,8 @@ namespace SabreTools.Helper
|
||||
DatFile innerDatdata = (DatFile)Clone();
|
||||
innerDatdata.Files = null;
|
||||
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 (innerDatdata.Files != null && innerDatdata.Files.Count != 0)
|
||||
@@ -3513,7 +3505,10 @@ namespace SabreTools.Helper
|
||||
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 (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)rom).Size = Constants.SizeZero;
|
||||
@@ -3589,6 +3584,10 @@ namespace SabreTools.Helper
|
||||
(ForceMerging == ForceMerging.Split ? "\tforcemerging split\n" : "") +
|
||||
")\n";
|
||||
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:
|
||||
header = "DOSCenter (\n" +
|
||||
"Name: " + Name + "\"\n" +
|
||||
@@ -3630,17 +3629,9 @@ namespace SabreTools.Helper
|
||||
: "") +
|
||||
"\t</header>\n";
|
||||
break;
|
||||
case OutputFormat.MissFile:
|
||||
if (XSV == true)
|
||||
{
|
||||
case OutputFormat.TSV:
|
||||
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";
|
||||
}
|
||||
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;
|
||||
case OutputFormat.OfflineList:
|
||||
header = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
|
||||
@@ -3957,7 +3948,7 @@ namespace SabreTools.Helper
|
||||
|
||||
try
|
||||
{
|
||||
string state = "";
|
||||
string state = "", name = "", pre = "", post = "";
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormat.ClrMamePro:
|
||||
@@ -4008,6 +3999,84 @@ namespace SabreTools.Helper
|
||||
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;
|
||||
case OutputFormat.DOSCenter:
|
||||
switch (rom.Type)
|
||||
@@ -4078,13 +4147,13 @@ namespace SabreTools.Helper
|
||||
break;
|
||||
case OutputFormat.MissFile:
|
||||
// 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;
|
||||
}
|
||||
|
||||
string pre = Prefix + (Quotes ? "\"" : "");
|
||||
string post = (Quotes ? "\"" : "") + Postfix;
|
||||
pre = Prefix + (Quotes ? "\"" : "");
|
||||
post = (Quotes ? "\"" : "") + Postfix;
|
||||
|
||||
if (rom.Type == ItemType.Rom)
|
||||
{
|
||||
@@ -4127,7 +4196,7 @@ namespace SabreTools.Helper
|
||||
// We can only write out if there's a SHA-1
|
||||
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(4, 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
|
||||
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(4, 2)
|
||||
+ "/" + ((Disk)rom).SHA1.Substring(6, 2)
|
||||
@@ -4149,50 +4218,9 @@ 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
|
||||
else
|
||||
{
|
||||
string name = (UseGame ? rom.MachineName : rom.Name);
|
||||
name = (UseGame ? rom.MachineName : rom.Name);
|
||||
if (RepExt != "" || RemExt)
|
||||
{
|
||||
if (RemExt)
|
||||
@@ -4222,7 +4250,6 @@ namespace SabreTools.Helper
|
||||
{
|
||||
state += pre + name + post + "\n";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OutputFormat.OfflineList:
|
||||
state += "\t\t<game>\n"
|
||||
@@ -4452,6 +4479,84 @@ namespace SabreTools.Helper
|
||||
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);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
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 (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))
|
||||
{
|
||||
|
||||
@@ -163,9 +163,16 @@ Options:
|
||||
files themselves. This is good for uncompressed sets that include archives that
|
||||
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
|
||||
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
|
||||
Add outputting the created DAT to DOSCenter format
|
||||
|
||||
@@ -193,6 +200,9 @@ Options:
|
||||
-osl, --output-sl Output in Software List 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)
|
||||
Add outputting the created DAT to Logiqx XML format
|
||||
|
||||
@@ -374,9 +384,33 @@ Options:
|
||||
to a DAT, or set of DATs. This is also a combination of many different programs
|
||||
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
|
||||
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
|
||||
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. 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
|
||||
Add outputting the created DAT to MD5 format
|
||||
|
||||
@@ -457,6 +485,26 @@ Options:
|
||||
-osl, --output-sl Output in Software List 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)
|
||||
Add outputting the created DAT to Logiqx XML format
|
||||
|
||||
|
||||
@@ -173,6 +173,12 @@ namespace SabreTools.Helper
|
||||
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
|
||||
if ((datdata.OutputFormat & OutputFormat.DOSCenter) != 0
|
||||
&& (datdata.OutputFormat & OutputFormat.ClrMamePro) == 0
|
||||
@@ -187,6 +193,12 @@ namespace SabreTools.Helper
|
||||
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
|
||||
if ((datdata.OutputFormat & OutputFormat.MissFile) != 0)
|
||||
{
|
||||
@@ -263,10 +275,10 @@ namespace SabreTools.Helper
|
||||
outfileNames.Add(OutputFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".sl.xml", datdata, overwrite));
|
||||
}
|
||||
|
||||
// Logiqx XML
|
||||
if ((datdata.OutputFormat & OutputFormat.Logiqx) != 0)
|
||||
// TSV
|
||||
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;
|
||||
|
||||
@@ -379,7 +379,6 @@ namespace SabreTools
|
||||
/// <param name="remext">Remove all extensions</param>
|
||||
/// <param name="datprefix">Add the dat name as a directory prefix</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 */
|
||||
/// <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>
|
||||
@@ -440,7 +439,6 @@ namespace SabreTools
|
||||
bool remext,
|
||||
bool datprefix,
|
||||
bool romba,
|
||||
bool? tsv,
|
||||
|
||||
/* Merging and Diffing info */
|
||||
bool merge,
|
||||
@@ -615,7 +613,6 @@ namespace SabreTools
|
||||
RemExt = remext,
|
||||
GameName = datprefix,
|
||||
Romba = romba,
|
||||
XSV = tsv,
|
||||
};
|
||||
|
||||
userInputDat.Update(inputs, outDir, merge, diffMode, inplace, skip, bare, clean, softlist,
|
||||
|
||||
@@ -86,7 +86,6 @@ namespace SabreTools
|
||||
trim = false,
|
||||
skip = false,
|
||||
usegame = true;
|
||||
bool? tsv = null;
|
||||
DiffMode diffMode = 0x0;
|
||||
int maxParallelism = 4;
|
||||
long sgt = -1,
|
||||
@@ -174,7 +173,6 @@ namespace SabreTools
|
||||
break;
|
||||
case "-csv":
|
||||
case "--csv":
|
||||
tsv = false;
|
||||
statOutputFormat = StatOutputFormat.CSV;
|
||||
break;
|
||||
case "-clean":
|
||||
@@ -254,10 +252,18 @@ namespace SabreTools
|
||||
case "--noSHA1":
|
||||
noSHA1 = true;
|
||||
break;
|
||||
case "-oa":
|
||||
case "--output-all":
|
||||
outputFormat |= OutputFormat.ALL;
|
||||
break;
|
||||
case "-oc":
|
||||
case "--output-cmp":
|
||||
outputFormat |= OutputFormat.ClrMamePro;
|
||||
break;
|
||||
case "-ocsv":
|
||||
case "--output-csv":
|
||||
outputFormat |= OutputFormat.CSV;
|
||||
break;
|
||||
case "-od":
|
||||
case "--output-dc":
|
||||
outputFormat |= OutputFormat.DOSCenter;
|
||||
@@ -294,6 +300,10 @@ namespace SabreTools
|
||||
case "--output-sl":
|
||||
outputFormat |= OutputFormat.SoftwareList;
|
||||
break;
|
||||
case "-otsv":
|
||||
case "--output-tsv":
|
||||
outputFormat |= OutputFormat.TSV;
|
||||
break;
|
||||
case "-ox":
|
||||
case "--output-xml":
|
||||
outputFormat |= OutputFormat.Logiqx;
|
||||
@@ -352,7 +362,6 @@ namespace SabreTools
|
||||
break;
|
||||
case "-tsv":
|
||||
case "--tsv":
|
||||
tsv = true;
|
||||
statOutputFormat = StatOutputFormat.TSV;
|
||||
break;
|
||||
case "-ud":
|
||||
@@ -621,11 +630,11 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// 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,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user