mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix outputted DAT information
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user