Minor logging and fixes

This commit is contained in:
Matt Nadareski
2016-04-23 00:29:48 -07:00
parent 2655aa12da
commit fdf6047f21
2 changed files with 13 additions and 9 deletions

View File

@@ -75,9 +75,9 @@ namespace SabreTools
public bool Process() public bool Process()
{ {
// Check if there are enough inputs // Check if there are enough inputs
if (_inputs.Count < 0) if (_inputs.Count < 2)
{ {
_logger.Warning("At least inputs are required!"); _logger.Warning("At least 2 inputs are required!");
return false; return false;
} }

View File

@@ -36,21 +36,25 @@ namespace SabreTools.Helper
/// <returns>The XmlDocument representing the (possibly converted) file, null otherwise</returns> /// <returns>The XmlDocument representing the (possibly converted) file, null otherwise</returns>
public static XmlDocument GetXmlDocument(string filename, Logger logger) public static XmlDocument GetXmlDocument(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;
}
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
string alltext = "";
string[] alllines;
try try
{ {
alltext = File.ReadAllText(filename); doc.LoadXml(File.ReadAllText(filename));
doc.LoadXml(alltext);
} }
catch (XmlException) catch (XmlException)
{ {
try try
{ {
alllines = File.ReadAllLines(filename); doc.LoadXml(Converters.ClrMameProToXML(File.ReadAllLines(filename)).ToString());
alltext = Converters.ClrMameProToXML(alllines).ToString();
doc.LoadXml(alltext);
} }
catch (Exception ex) catch (Exception ex)
{ {