diff --git a/DatSplit/DatSplit.cs b/DatSplit/DatSplit.cs index 97a4c1ee..7858d652 100644 --- a/DatSplit/DatSplit.cs +++ b/DatSplit/DatSplit.cs @@ -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(); } diff --git a/SabreHelper/RomManipulation.cs b/SabreHelper/RomManipulation.cs index 8934e02c..5c57a172 100644 --- a/SabreHelper/RomManipulation.cs +++ b/SabreHelper/RomManipulation.cs @@ -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; + } } } diff --git a/SingleGame/SingleGame.cs b/SingleGame/SingleGame.cs index 5a5d5227..df399717 100644 --- a/SingleGame/SingleGame.cs +++ b/SingleGame/SingleGame.cs @@ -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); } } }