mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatTools] Continuation of last
This commit is contained in:
@@ -21,9 +21,9 @@ namespace SabreTools.Helper
|
||||
/// Get what type of DAT the input file is
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <returns>The OutputFormatFlagcorresponding to the DAT</returns>
|
||||
/// <returns>The OutputFormat corresponding to the DAT</returns>
|
||||
/// <remarks>There is currently no differentiation between XML and SabreDAT here</remarks>
|
||||
public static OutputFormatFlag GetOutputFormat(string filename, Logger logger)
|
||||
public static OutputFormat GetOutputFormat(string filename, Logger logger)
|
||||
{
|
||||
// Limit the output formats based on extension
|
||||
string ext = Path.GetExtension(filename).ToLowerInvariant();
|
||||
@@ -50,15 +50,15 @@ namespace SabreTools.Helper
|
||||
sr.Dispose();
|
||||
if (first.Contains("<") && first.Contains(">"))
|
||||
{
|
||||
return OutputFormatFlag.Xml;
|
||||
return OutputFormat.Xml;
|
||||
}
|
||||
else if (first.Contains("[") && first.Contains("]"))
|
||||
{
|
||||
return OutputFormatFlag.RomCenter;
|
||||
return OutputFormat.RomCenter;
|
||||
}
|
||||
else
|
||||
{
|
||||
return OutputFormatFlag.ClrMamePro;
|
||||
return OutputFormat.ClrMamePro;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -175,7 +175,7 @@ namespace SabreTools.Helper
|
||||
datdata.FileName = (String.IsNullOrEmpty(datdata.FileName) ? (keepext ? Path.GetFileName(filename) : Path.GetFileNameWithoutExtension(filename)) : datdata.FileName);
|
||||
|
||||
// If the output type isn't set already, get the internal output type
|
||||
datdata.OutputFormatFlag = (datdata.OutputFormatFlag == 0 ? GetOutputFormat(filename, logger) : datdata.OutputFormatFlag);
|
||||
datdata.OutputFormat = (datdata.OutputFormat == 0 ? GetOutputFormat(filename, logger) : datdata.OutputFormat);
|
||||
|
||||
// Make sure there's a dictionary to read to
|
||||
if (datdata.Files == null)
|
||||
@@ -186,12 +186,12 @@ namespace SabreTools.Helper
|
||||
// Now parse the correct type of DAT
|
||||
switch (GetOutputFormat(filename, logger))
|
||||
{
|
||||
case OutputFormatFlag.ClrMamePro:
|
||||
case OutputFormat.ClrMamePro:
|
||||
return ParseCMP(filename, sysid, srcid, datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger, keep, clean);
|
||||
case OutputFormatFlag.RomCenter:
|
||||
case OutputFormat.RomCenter:
|
||||
return ParseRC(filename, sysid, srcid, datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger, clean);
|
||||
case OutputFormatFlag.SabreDat:
|
||||
case OutputFormatFlag.Xml:
|
||||
case OutputFormat.SabreDat:
|
||||
case OutputFormat.Xml:
|
||||
return ParseXML(filename, sysid, srcid, datdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger, keep, clean, softlist);
|
||||
default:
|
||||
return datdata;
|
||||
@@ -1842,7 +1842,7 @@ namespace SabreTools.Helper
|
||||
int i = 0;
|
||||
userData = new Dat
|
||||
{
|
||||
OutputFormatFlag = (inputDat.OutputFormatFlag != 0 ? inputDat.OutputFormatFlag : 0),
|
||||
OutputFormat = (inputDat.OutputFormat != 0 ? inputDat.OutputFormat : 0),
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
MergeRoms = inputDat.MergeRoms,
|
||||
};
|
||||
@@ -1862,7 +1862,7 @@ namespace SabreTools.Helper
|
||||
Dictionary<string, List<Rom>> temp = userData.Files;
|
||||
userData = new Dat
|
||||
{
|
||||
OutputFormatFlag = (inputDat.OutputFormatFlag != 0 ? inputDat.OutputFormatFlag : 0),
|
||||
OutputFormat = (inputDat.OutputFormat != 0 ? inputDat.OutputFormat : 0),
|
||||
Files = temp,
|
||||
MergeRoms = inputDat.MergeRoms,
|
||||
};
|
||||
@@ -2410,7 +2410,7 @@ namespace SabreTools.Helper
|
||||
/// </summary>
|
||||
/// <param name="inputFileNames">Names of the input files and/or folders</param>
|
||||
/// <param name="datdata">User specified inputs contained in a DatData object</param>
|
||||
/// <param name="outputFormatFlag">Non-zero flag for output format, zero otherwise for default</param>
|
||||
/// <param name="outputFormat">Non-zero flag for output format, zero otherwise for default</param>
|
||||
/// <param name="outputDirectory">Optional param for output directory</param>
|
||||
/// <param name="merge">True if input files should be merged into a single file, false otherwise</param>
|
||||
/// <param name="diff">Non-zero flag for diffing mode, zero otherwise</param>
|
||||
@@ -2435,7 +2435,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="root">String representing root directory to compare against for length calculation</param>
|
||||
/// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
|
||||
/// <param name="logger">Logging object for console and file output</param>
|
||||
public static void UpdateParallel(List<string> inputFileNames, Dat datdata, OutputFormatFlag outputFormatFlag, string outputDirectory, bool merge,
|
||||
public static void UpdateParallel(List<string> inputFileNames, Dat datdata, OutputFormat outputFormat, string outputDirectory, bool merge,
|
||||
DiffMode diff, bool? cascade, bool inplace, bool skip, bool bare, bool clean, bool softlist, string gamename, string romname, string romtype,
|
||||
long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, bool trim, bool single, string root, int maxDegreeOfParallelism,
|
||||
Logger logger)
|
||||
@@ -2597,7 +2597,7 @@ namespace SabreTools.Helper
|
||||
|
||||
userData = new Dat
|
||||
{
|
||||
OutputFormatFlag = (inputDat.OutputFormatFlag != 0 ? inputDat.OutputFormatFlag: 0),
|
||||
OutputFormat = (inputDat.OutputFormat != 0 ? inputDat.OutputFormat: 0),
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
MergeRoms = inputDat.MergeRoms,
|
||||
};
|
||||
@@ -2608,7 +2608,7 @@ namespace SabreTools.Helper
|
||||
logger.User("Adding DAT: " + input.Split('¬')[0]);
|
||||
datHeaders[i] = new Dat
|
||||
{
|
||||
OutputFormatFlag = (inputDat.OutputFormatFlag != 0 ? inputDat.OutputFormatFlag: 0),
|
||||
OutputFormat = (inputDat.OutputFormat != 0 ? inputDat.OutputFormat: 0),
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
MergeRoms = inputDat.MergeRoms,
|
||||
};
|
||||
@@ -2684,9 +2684,9 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// If the DAT has no output format, default to XML
|
||||
if (datdata.OutputFormatFlag == 0)
|
||||
if (datdata.OutputFormat == 0)
|
||||
{
|
||||
datdata.OutputFormatFlag = OutputFormatFlag.Xml;
|
||||
datdata.OutputFormat = OutputFormat.Xml;
|
||||
}
|
||||
|
||||
// Make sure that the three essential fields are filled in
|
||||
@@ -2733,20 +2733,20 @@ namespace SabreTools.Helper
|
||||
SortedDictionary<string, List<Rom>> sortable = BucketByGame(datdata.Files, datdata.MergeRoms, norename, logger);
|
||||
|
||||
// Get the outfile name
|
||||
Dictionary<OutputFormatFlag, string> outfiles = Style.CreateOutfileNames(outDir, datdata, overwrite);
|
||||
Dictionary<OutputFormat, string> outfiles = Style.CreateOutfileNames(outDir, datdata, overwrite);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (OutputFormatFlag outputFormatFlag in outfiles.Keys)
|
||||
foreach (OutputFormat outputFormat in outfiles.Keys)
|
||||
{
|
||||
string outfile = outfiles[outputFormatFlag];
|
||||
string outfile = outfiles[outputFormat];
|
||||
|
||||
logger.User("Opening file for writing: " + outfile);
|
||||
FileStream fs = File.Create(outfile);
|
||||
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
|
||||
|
||||
// Write out the header
|
||||
WriteHeader(sw, outputFormatFlag, datdata, logger);
|
||||
WriteHeader(sw, outputFormat, datdata, logger);
|
||||
|
||||
// Write out each of the machines and roms
|
||||
int depth = 2, last = -1;
|
||||
@@ -2769,13 +2769,13 @@ namespace SabreTools.Helper
|
||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
{
|
||||
depth = WriteEndGame(sw, outputFormatFlag, rom, splitpath, newsplit, lastgame, depth, out last, logger);
|
||||
depth = WriteEndGame(sw, outputFormat, rom, splitpath, newsplit, lastgame, depth, out last, logger);
|
||||
}
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
{
|
||||
depth = WriteStartGame(sw, outputFormatFlag, rom, newsplit, lastgame, depth, last, logger);
|
||||
depth = WriteStartGame(sw, outputFormat, rom, newsplit, lastgame, depth, last, logger);
|
||||
}
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
@@ -2784,7 +2784,7 @@ namespace SabreTools.Helper
|
||||
logger.Log("Empty folder found: " + rom.Machine.Name);
|
||||
|
||||
// If we're in a mode that doesn't allow for actual empty folders, add the blank info
|
||||
if (outputFormatFlag != OutputFormatFlag.SabreDat && outputFormatFlag != OutputFormatFlag.MissFile)
|
||||
if (outputFormat != OutputFormat.SabreDat && outputFormat != OutputFormat.MissFile)
|
||||
{
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
rom.HashData.Size = Constants.SizeZero;
|
||||
@@ -2803,7 +2803,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
WriteRomData(sw, outputFormatFlag, rom, lastgame, datdata, depth, logger, ignoreblanks);
|
||||
WriteRomData(sw, outputFormat, rom, lastgame, datdata, depth, logger, ignoreblanks);
|
||||
|
||||
// Set the new data to compare against
|
||||
splitpath = newsplit;
|
||||
@@ -2812,7 +2812,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
// Write the file footer out
|
||||
WriteFooter(sw, outputFormatFlag, datdata, depth, logger);
|
||||
WriteFooter(sw, outputFormat, datdata, depth, logger);
|
||||
|
||||
logger.Log("File written!" + Environment.NewLine);
|
||||
sw.Close();
|
||||
@@ -2832,18 +2832,18 @@ namespace SabreTools.Helper
|
||||
/// Write out DAT header using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="outputFormatFlag">Output format to write to</param>
|
||||
/// <param name="outputFormat">Output format to write to</param>
|
||||
/// <param name="datdata">DatData object representing DAT information</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
public static bool WriteHeader(StreamWriter sw, OutputFormatFlag outputFormatFlag, Dat datdata, Logger logger)
|
||||
public static bool WriteHeader(StreamWriter sw, OutputFormat outputFormat, Dat datdata, Logger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
string header = "";
|
||||
switch (outputFormatFlag)
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormatFlag.ClrMamePro:
|
||||
case OutputFormat.ClrMamePro:
|
||||
header = "clrmamepro (\n" +
|
||||
"\tname \"" + datdata.Name + "\"\n" +
|
||||
"\tdescription \"" + datdata.Description + "\"\n" +
|
||||
@@ -2858,7 +2858,7 @@ namespace SabreTools.Helper
|
||||
(datdata.ForcePacking == ForcePacking.Unzip ? "\tforcezipping no\n" : "") +
|
||||
")\n";
|
||||
break;
|
||||
case OutputFormatFlag.MissFile:
|
||||
case OutputFormat.MissFile:
|
||||
if (datdata.XSV == true)
|
||||
{
|
||||
header = "\"File Name\"\t\"Internal Name\"\t\"Description\"\t\"Game Name\"\t\"Game Description\"\t\"Type\"\t\"" +
|
||||
@@ -2870,7 +2870,7 @@ namespace SabreTools.Helper
|
||||
"Rom Name\",\"Disk Name\",\"Size\",\"CRC\",\"MD5\",\"SHA1\",\"Nodump\"\n";
|
||||
}
|
||||
break;
|
||||
case OutputFormatFlag.RomCenter:
|
||||
case OutputFormat.RomCenter:
|
||||
header = "[CREDITS]\n" +
|
||||
"author=" + datdata.Author + "\n" +
|
||||
"version=" + datdata.Version + "\n" +
|
||||
@@ -2884,7 +2884,7 @@ namespace SabreTools.Helper
|
||||
"version=" + datdata.Description + "\n" +
|
||||
"[GAMES]\n";
|
||||
break;
|
||||
case OutputFormatFlag.SabreDat:
|
||||
case OutputFormat.SabreDat:
|
||||
header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<!DOCTYPE datafile PUBLIC \"-//Logiqx//DTD ROM Management Datafile//EN\" \"http://www.logiqx.com/Dats/datafile.dtd\">\n\n" +
|
||||
"<datafile>\n" +
|
||||
@@ -2905,7 +2905,7 @@ namespace SabreTools.Helper
|
||||
"\t</header>\n" +
|
||||
"\t<data>\n";
|
||||
break;
|
||||
case OutputFormatFlag.Xml:
|
||||
case OutputFormat.Xml:
|
||||
header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<!DOCTYPE datafile PUBLIC \"-//Logiqx//DTD ROM Management Datafile//EN\" \"http://www.logiqx.com/Dats/datafile.dtd\">\n\n" +
|
||||
"<datafile>\n" +
|
||||
@@ -2943,7 +2943,7 @@ namespace SabreTools.Helper
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="outputFormatFlag">Output format to write to</param>
|
||||
/// <param name="outputFormat">Output format to write to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="newsplit">Split path representing the parent game (SabreDAT only)</param>
|
||||
/// <param name="lastgame">The name of the last game to be output</param>
|
||||
@@ -2951,7 +2951,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>The new depth of the tag</returns>
|
||||
public static int WriteStartGame(StreamWriter sw, OutputFormatFlag outputFormatFlag, Rom rom, List<string> newsplit, string lastgame, int depth, int last, Logger logger)
|
||||
public static int WriteStartGame(StreamWriter sw, OutputFormat outputFormat, Rom rom, List<string> newsplit, string lastgame, int depth, int last, Logger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -2962,13 +2962,13 @@ namespace SabreTools.Helper
|
||||
}
|
||||
|
||||
string state = "";
|
||||
switch (outputFormatFlag)
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormatFlag.ClrMamePro:
|
||||
case OutputFormat.ClrMamePro:
|
||||
state += "game (\n\tname \"" + rom.Machine.Name + "\"\n" +
|
||||
"\tdescription \"" + (String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description) + "\"\n";
|
||||
break;
|
||||
case OutputFormatFlag.SabreDat:
|
||||
case OutputFormat.SabreDat:
|
||||
for (int i = (last == -1 ? 0 : last); i < newsplit.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < depth - last + i - (lastgame == null ? 1 : 0); j++)
|
||||
@@ -2980,7 +2980,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
depth = depth - (last == -1 ? 0 : last) + newsplit.Count;
|
||||
break;
|
||||
case OutputFormatFlag.Xml:
|
||||
case OutputFormat.Xml:
|
||||
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.Machine.Name) + "\">\n" +
|
||||
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description)) + "</description>\n";
|
||||
break;
|
||||
@@ -3001,7 +3001,7 @@ namespace SabreTools.Helper
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="outputFormatFlag">Output format to write to</param>
|
||||
/// <param name="outputFormat">Output format to write to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="splitpath">Split path representing last kwown parent game (SabreDAT only)</param>
|
||||
/// <param name="newsplit">Split path representing the parent game (SabreDAT only)</param>
|
||||
@@ -3010,7 +3010,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="last">Last known depth to cycle back from (SabreDAT only)</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>The new depth of the tag</returns>
|
||||
public static int WriteEndGame(StreamWriter sw, OutputFormatFlag outputFormatFlag, Rom rom, List<string> splitpath, List<string> newsplit, string lastgame, int depth, out int last, Logger logger)
|
||||
public static int WriteEndGame(StreamWriter sw, OutputFormat outputFormat, Rom rom, List<string> splitpath, List<string> newsplit, string lastgame, int depth, out int last, Logger logger)
|
||||
{
|
||||
last = 0;
|
||||
|
||||
@@ -3018,12 +3018,12 @@ namespace SabreTools.Helper
|
||||
{
|
||||
string state = "";
|
||||
|
||||
switch (outputFormatFlag)
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormatFlag.ClrMamePro:
|
||||
case OutputFormat.ClrMamePro:
|
||||
state += ")\n";
|
||||
break;
|
||||
case OutputFormatFlag.SabreDat:
|
||||
case OutputFormat.SabreDat:
|
||||
if (splitpath != null)
|
||||
{
|
||||
for (int i = 0; i < newsplit.Count && i < splitpath.Count; i++)
|
||||
@@ -3053,7 +3053,7 @@ namespace SabreTools.Helper
|
||||
depth = 2 + last;
|
||||
}
|
||||
break;
|
||||
case OutputFormatFlag.Xml:
|
||||
case OutputFormat.Xml:
|
||||
state += "\t</machine>\n";
|
||||
break;
|
||||
}
|
||||
@@ -3073,7 +3073,7 @@ namespace SabreTools.Helper
|
||||
/// Write out RomData using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="sw">StreamWriter to output to</param>
|
||||
/// <param name="outputFormatFlag">Output format to write to</param>
|
||||
/// <param name="outputFormat">Output format to write to</param>
|
||||
/// <param name="rom">RomData object to be output</param>
|
||||
/// <param name="lastgame">The name of the last game to be output</param>
|
||||
/// <param name="datdata">DatData object representing DAT information</param>
|
||||
@@ -3081,7 +3081,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
public static bool WriteRomData(StreamWriter sw, OutputFormatFlag outputFormatFlag, Rom rom, string lastgame, Dat datdata, int depth, Logger logger, bool ignoreblanks = false)
|
||||
public static bool WriteRomData(StreamWriter sw, OutputFormat outputFormat, Rom rom, string lastgame, Dat datdata, int depth, Logger logger, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks && (rom.HashData.Size == 0 || rom.HashData.Size == -1))
|
||||
@@ -3092,9 +3092,9 @@ namespace SabreTools.Helper
|
||||
try
|
||||
{
|
||||
string state = "";
|
||||
switch (outputFormatFlag)
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormatFlag.ClrMamePro:
|
||||
case OutputFormat.ClrMamePro:
|
||||
state += "\t" + rom.Type.ToString().ToLowerInvariant() + " ( name \"" + rom.Name + "\"" +
|
||||
(rom.HashData.Size != -1 ? " size " + rom.HashData.Size : "") +
|
||||
(!String.IsNullOrEmpty(rom.HashData.CRC) ? " crc " + rom.HashData.CRC.ToLowerInvariant() : "") +
|
||||
@@ -3104,7 +3104,7 @@ namespace SabreTools.Helper
|
||||
(rom.Nodump ? " flags nodump" : "") +
|
||||
" )\n";
|
||||
break;
|
||||
case OutputFormatFlag.MissFile:
|
||||
case OutputFormat.MissFile:
|
||||
string pre = datdata.Prefix + (datdata.Quotes ? "\"" : "");
|
||||
string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix;
|
||||
|
||||
@@ -3169,23 +3169,23 @@ namespace SabreTools.Helper
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OutputFormatFlag.RedumpMD5:
|
||||
case OutputFormat.RedumpMD5:
|
||||
state += rom.HashData.MD5 + " *" + rom.Name + "\n";
|
||||
break;
|
||||
case OutputFormatFlag.RedumpSFV:
|
||||
case OutputFormat.RedumpSFV:
|
||||
state += rom.Name + " " + rom.HashData.CRC + "\n";
|
||||
break;
|
||||
case OutputFormatFlag.RedumpSHA1:
|
||||
case OutputFormat.RedumpSHA1:
|
||||
state += rom.HashData.SHA1 + " *" + rom.Name + "\n";
|
||||
break;
|
||||
case OutputFormatFlag.RomCenter:
|
||||
case OutputFormat.RomCenter:
|
||||
state += "¬¬¬" + HttpUtility.HtmlEncode(rom.Machine) +
|
||||
"¬" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.Machine.Description) ? rom.Machine.Name : rom.Machine.Description)) +
|
||||
"¬" + HttpUtility.HtmlEncode(rom.Name) +
|
||||
"¬" + rom.HashData.CRC.ToLowerInvariant() +
|
||||
"¬" + (rom.HashData.Size != -1 ? rom.HashData.Size.ToString() : "") + "¬¬¬\n";
|
||||
break;
|
||||
case OutputFormatFlag.SabreDat:
|
||||
case OutputFormat.SabreDat:
|
||||
string prefix = "";
|
||||
for (int i = 0; i < depth; i++)
|
||||
{
|
||||
@@ -3205,7 +3205,7 @@ namespace SabreTools.Helper
|
||||
prefix + "</file>\n" :
|
||||
"/>\n");
|
||||
break;
|
||||
case OutputFormatFlag.Xml:
|
||||
case OutputFormat.Xml:
|
||||
state += "\t\t<" + rom.Type.ToString().ToLowerInvariant() + " name=\"" + HttpUtility.HtmlEncode(rom.Name) + "\"" +
|
||||
(rom.HashData.Size != -1 ? " size=\"" + rom.HashData.Size + "\"" : "") +
|
||||
(!String.IsNullOrEmpty(rom.HashData.CRC) ? " crc=\"" + rom.HashData.CRC.ToLowerInvariant() + "\"" : "") +
|
||||
@@ -3236,7 +3236,7 @@ namespace SabreTools.Helper
|
||||
/// <param name="depth">Current depth to output file at (SabreDAT only)</param>
|
||||
/// <param name="logger">Logger object for file and console output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
public static bool WriteFooter(StreamWriter sw, OutputFormatFlag outputFormatFlag, Dat datdata, int depth, Logger logger)
|
||||
public static bool WriteFooter(StreamWriter sw, OutputFormat outputFormat, Dat datdata, int depth, Logger logger)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -3245,12 +3245,12 @@ namespace SabreTools.Helper
|
||||
// If we have roms, output the full footer
|
||||
if (datdata.Files != null && datdata.Files.Count > 0)
|
||||
{
|
||||
switch (outputFormatFlag)
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormatFlag.ClrMamePro:
|
||||
case OutputFormat.ClrMamePro:
|
||||
footer = ")";
|
||||
break;
|
||||
case OutputFormatFlag.SabreDat:
|
||||
case OutputFormat.SabreDat:
|
||||
for (int i = depth - 1; i >= 2; i--)
|
||||
{
|
||||
// Print out the number of tabs and the end folder
|
||||
@@ -3262,7 +3262,7 @@ namespace SabreTools.Helper
|
||||
}
|
||||
footer += "\t</data>\n</datafile>";
|
||||
break;
|
||||
case OutputFormatFlag.Xml:
|
||||
case OutputFormat.Xml:
|
||||
footer = "\t</machine>\n</datafile>";
|
||||
break;
|
||||
}
|
||||
@@ -3271,10 +3271,10 @@ namespace SabreTools.Helper
|
||||
// Otherwise, output the abbreviated form
|
||||
else
|
||||
{
|
||||
switch (outputFormatFlag)
|
||||
switch (outputFormat)
|
||||
{
|
||||
case OutputFormatFlag.SabreDat:
|
||||
case OutputFormatFlag.Xml:
|
||||
case OutputFormat.SabreDat:
|
||||
case OutputFormat.Xml:
|
||||
footer = "</datafile>";
|
||||
break;
|
||||
}
|
||||
@@ -3324,8 +3324,8 @@ namespace SabreTools.Helper
|
||||
string newExtBString = string.Join(",", newExtB);
|
||||
|
||||
// Get the file format
|
||||
OutputFormatFlag outputFormatFlag = GetOutputFormat(filename, logger);
|
||||
if (outputFormatFlag == 0)
|
||||
OutputFormat outputFormat = GetOutputFormat(filename, logger);
|
||||
if (outputFormat == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -3349,7 +3349,7 @@ namespace SabreTools.Helper
|
||||
Url = datdata.Url,
|
||||
Comment = datdata.Comment,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
};
|
||||
Dat datdataB = new Dat
|
||||
{
|
||||
@@ -3365,7 +3365,7 @@ namespace SabreTools.Helper
|
||||
Url = datdata.Url,
|
||||
Comment = datdata.Comment,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
};
|
||||
|
||||
// If roms is empty, return false
|
||||
@@ -3462,8 +3462,8 @@ namespace SabreTools.Helper
|
||||
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
|
||||
|
||||
// Get the file format
|
||||
OutputFormatFlag outputFormatFlag = GetOutputFormat(filename, logger);
|
||||
if (outputFormatFlag == 0)
|
||||
OutputFormat outputFormat = GetOutputFormat(filename, logger);
|
||||
if (outputFormat == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -3492,7 +3492,7 @@ namespace SabreTools.Helper
|
||||
ForceMerging = datdata.ForceMerging,
|
||||
ForceNodump = datdata.ForceNodump,
|
||||
ForcePacking = datdata.ForcePacking,
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
MergeRoms = datdata.MergeRoms,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
};
|
||||
@@ -3514,7 +3514,7 @@ namespace SabreTools.Helper
|
||||
ForceMerging = datdata.ForceMerging,
|
||||
ForceNodump = datdata.ForceNodump,
|
||||
ForcePacking = datdata.ForcePacking,
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
MergeRoms = datdata.MergeRoms,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
};
|
||||
@@ -3536,7 +3536,7 @@ namespace SabreTools.Helper
|
||||
ForceMerging = datdata.ForceMerging,
|
||||
ForceNodump = datdata.ForceNodump,
|
||||
ForcePacking = datdata.ForcePacking,
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
MergeRoms = datdata.MergeRoms,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
};
|
||||
@@ -3558,7 +3558,7 @@ namespace SabreTools.Helper
|
||||
ForceMerging = datdata.ForceMerging,
|
||||
ForceNodump = datdata.ForceNodump,
|
||||
ForcePacking = datdata.ForcePacking,
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
MergeRoms = datdata.MergeRoms,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
};
|
||||
@@ -3676,8 +3676,8 @@ namespace SabreTools.Helper
|
||||
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
|
||||
|
||||
// Get the file format
|
||||
OutputFormatFlag outputFormatFlag = GetOutputFormat(filename, logger);
|
||||
if (outputFormatFlag == 0)
|
||||
OutputFormat outputFormat = GetOutputFormat(filename, logger);
|
||||
if (outputFormat == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -3706,7 +3706,7 @@ namespace SabreTools.Helper
|
||||
ForceMerging = datdata.ForceMerging,
|
||||
ForceNodump = datdata.ForceNodump,
|
||||
ForcePacking = datdata.ForcePacking,
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
MergeRoms = datdata.MergeRoms,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
};
|
||||
@@ -3728,7 +3728,7 @@ namespace SabreTools.Helper
|
||||
ForceMerging = datdata.ForceMerging,
|
||||
ForceNodump = datdata.ForceNodump,
|
||||
ForcePacking = datdata.ForcePacking,
|
||||
OutputFormatFlag = outputFormatFlag,
|
||||
OutputFormat = outputFormat,
|
||||
MergeRoms = datdata.MergeRoms,
|
||||
Files = new Dictionary<string, List<Rom>>(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user