mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add retrieval of XmlTextReader
This commit is contained in:
@@ -80,6 +80,36 @@ namespace SabreTools.Helper
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the XmlTextReader associated with a file, if possible
|
||||||
|
/// </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 XmlTextReader representing the (possibly converted) file, null otherwise</returns>
|
||||||
|
public static XmlTextReader GetXmlTextReader(string filename, Logger logger)
|
||||||
|
{
|
||||||
|
logger.Log("Attempting to read file: " + filename);
|
||||||
|
|
||||||
|
// Check if file exists
|
||||||
|
if (!File.Exists(filename))
|
||||||
|
{
|
||||||
|
logger.Warning("File '" + filename + "' could not read from!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsXmlDat(filename))
|
||||||
|
{
|
||||||
|
logger.Log("XML DAT detected");
|
||||||
|
return new XmlTextReader(filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Log("Non-XML DAT detected");
|
||||||
|
StringReader sr = new StringReader(Converters.ClrMameProToXML(File.ReadAllLines(filename)).ToString());
|
||||||
|
return new XmlTextReader(sr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the name of the DAT for external use
|
/// Get the name of the DAT for external use
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user