Fix outputted DAT information

This commit is contained in:
Matt Nadareski
2016-04-21 14:35:11 -07:00
parent 4a7cfb071c
commit f2985b40cc
4 changed files with 55 additions and 6 deletions

View File

@@ -621,9 +621,7 @@ Make a selection:
/// </summary>
/// <remarks>
/// At an unspecified future date, this will also include the following currently-separate programs:
/// - MergeDAT
/// - DATFromDir
/// - DatToMiss
/// </remarks>
private static void DatToolsMenu()
{

View File

@@ -112,8 +112,8 @@ namespace SabreTools
}
// Now write the file out accordingly
Output.WriteToDat(Path.GetFileNameWithoutExtension(filename),
Path.GetFileNameWithoutExtension(filename), "", "", "", "", _forceunpack, !RomManipulation.IsXmlDat(filename), Path.GetDirectoryName(filename), outroms, _logger);
Output.WriteToDat(RomManipulation.GetDatName(filename, _logger), RomManipulation.GetDatDescription(filename, _logger),
"", "", "", "", _forceunpack, !RomManipulation.IsXmlDat(filename), Path.GetDirectoryName(filename), outroms, _logger);
// Remove the original file if different and inform the user
if (Path.GetExtension(filename) != (RomManipulation.IsXmlDat(filename) ? ".xml" : ".dat"))

View File

@@ -128,7 +128,7 @@ Options:
-c=, --cat= Set the category of the DAT
-v=, --version= Set the version of the DAT
-au=, --author= Set the author of the DAT
-rm, --remove Remove a system or source from the database
-rm, --remove Remove a system or source from the database
system= System ID
source= Source ID
-tm, --trim-merge Consolidate DAT into a single game and trim entries

View File

@@ -99,12 +99,63 @@ namespace SabreTools.Helper
// Get the name from the header
if (node != null && node.Name == "header")
{
name = node.SelectSingleNode("name").InnerText;
XmlNode temp = node.SelectSingleNode("name");
if (temp != null)
{
name = temp.InnerText;
}
}
return name;
}
/// <summary>
/// Get the description of the DAT for external use
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="logger">Logger object for console and file output</param>
/// <returns>The internal name of the DAT on success, empty string otherwise</returns>
public static string GetDatDescription(string filename, Logger logger)
{
string desc = "";
XmlDocument doc = GetXmlDocument(filename, logger);
// If the returned document is null, return the blank string
if (doc == null)
{
return desc;
}
// Experimental looping using only XML parsing
XmlNode node = doc.FirstChild;
if (node != null && node.Name == "xml")
{
// Skip over everything that's not an element
while (node.NodeType != XmlNodeType.Element)
{
node = node.NextSibling;
}
}
// Once we find the main body, enter it
if (node != null && (node.Name == "datafile" || node.Name == "softwarelist"))
{
node = node.FirstChild;
}
// Get the name from the header
if (node != null && node.Name == "header")
{
XmlNode temp = node.SelectSingleNode("description");
if (temp != null)
{
desc = temp.InnerText;
}
}
return desc;
}
/// <summary>
/// Parse a DAT and return all found games and roms within
/// </summary>