diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs index af9e63bb..ed4834f0 100644 --- a/SabreHelper/Output.cs +++ b/SabreHelper/Output.cs @@ -71,11 +71,8 @@ namespace SabreTools.Helper // Create the output directory if it doesn't already exist Directory.CreateDirectory(outDir); - // Get the outfile and clean the path - string outfile = outDir + datdata.Description + (datdata.OutputFormat == OutputFormat.Xml || datdata.OutputFormat == OutputFormat.SabreDat ? ".xml" : ".dat"); - outfile = (outfile.Contains(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString()) ? - outfile.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString()) : - outfile); + // Get the outfile name + string outfile = Style.CreateOutfileName(outDir, datdata); logger.User("Opening file for writing: " + outfile); diff --git a/SabreHelper/Style.cs b/SabreHelper/Style.cs index b4bdf7a0..6dd21ec1 100644 --- a/SabreHelper/Style.cs +++ b/SabreHelper/Style.cs @@ -139,25 +139,14 @@ namespace SabreTools.Helper return input; } - // http://stackoverflow.com/questions/203528/what-is-the-simplest-way-to-get-indented-xml-with-line-breaks-from-xmldocument - // http://www.timvw.be/2007/01/08/generating-utf-8-with-systemxmlxmlwriter/ - public static string Beautify(XmlDocument doc) + public static string CreateOutfileName(string outDir, DatData datdata) { - MemoryStream ms = new MemoryStream(); - XmlWriterSettings settings = new XmlWriterSettings - { - Encoding = new UTF8Encoding(false), - Indent = true, - IndentChars = "\t", - NewLineChars = "\r\n", - NewLineHandling = NewLineHandling.Replace - }; + string outfile = outDir + datdata.Description + (datdata.OutputFormat == OutputFormat.Xml || datdata.OutputFormat == OutputFormat.SabreDat ? ".xml" : ".dat"); + outfile = (outfile.Contains(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString()) ? + outfile.Replace(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString(), Path.DirectorySeparatorChar.ToString()) : + outfile); - using (XmlWriter writer = XmlWriter.Create(ms, settings)) - { - doc.Save(writer); - } - return Encoding.UTF8.GetString(ms.ToArray()); + return outfile; } } }