Extensions are confusing

This commit is contained in:
Matt Nadareski
2016-04-19 13:11:11 -07:00
parent 20aee2ffae
commit 788bf2d794
3 changed files with 17 additions and 3 deletions

View File

@@ -68,9 +68,9 @@ namespace DatSplit
// Then write out both files
Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extA, Path.GetFileNameWithoutExtension(_filename) + "." + _extA,
"", "", "", "", false, Path.GetExtension(_filename) == ".dat", "", romsA, logger);
"", "", "", "", false, !RomManipulation.IsXmlDat(_filename), "", romsA, logger);
Output.WriteToDat(Path.GetFileNameWithoutExtension(_filename) + "." + _extB, Path.GetFileNameWithoutExtension(_filename) + "." + _extB,
"", "", "", "", false, Path.GetExtension(_filename) == ".dat", "", romsB, logger);
"", "", "", "", false, !RomManipulation.IsXmlDat(_filename), "", romsB, logger);
logger.Close();
}

View File

@@ -292,5 +292,19 @@ namespace SabreTools.Helper
return (norename ? String.Compare(x.Game, y.Game) : x.SystemID - y.SystemID);
});
}
public static bool IsXmlDat(string filename)
{
XmlDocument doc = new XmlDocument();
try
{
doc.LoadXml(File.ReadAllText(filename));
}
catch (XmlException)
{
return false;
}
return true;
}
}
}

View File

@@ -133,7 +133,7 @@ namespace SabreTools
// Now write the file out accordingly
Output.WriteToDat(Path.GetFileNameWithoutExtension(filename),
Path.GetFileNameWithoutExtension(filename), "", "", "", "", _forceunpack, Path.GetExtension(filename) == ".dat", Path.GetDirectoryName(filename), outroms, logger);
Path.GetFileNameWithoutExtension(filename), "", "", "", "", _forceunpack, !RomManipulation.IsXmlDat(filename), Path.GetDirectoryName(filename), outroms, logger);
}
}
}