private static void PackSubp(string path, Encoding encoding) { string fileDirectory = Path.GetDirectoryName(path); string fileName = Path.GetFileNameWithoutExtension(path); string outputFileName = fileName + ".subp"; string outputFilePath = Path.Combine(fileDirectory, outputFileName); //tex really seems like there should be a way to access the xml declaration from xmlreader iteself, but I guess not Encoding xmlEncoding = FindXmlEncoding(path); if (xmlEncoding != null) { encoding = xmlEncoding; } using (FileStream inputStream = new FileStream(path, FileMode.Open)) using (XmlReader xmlReader = XmlReader.Create(inputStream, CreateXmlReaderSettings <SubpFile>())) using (FileStream outputStream = new FileStream(outputFilePath, FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(SubpFile)); SubpFile subpFile = serializer.Deserialize(xmlReader) as SubpFile; //tex vanilla files are sorted by hash ascending //subpFile.Entries = subpFile.Entries.OrderBy(o => o.SubtitleIdHash).ToList(); //DEBUGNOW subpFile?.Write(outputStream, encoding); } }
private static void PackSubp(string path, Encoding encoding) { string fileDirectory = Path.GetDirectoryName(path); string fileName = Path.GetFileNameWithoutExtension(path); string outputFileName = fileName + ".subp"; string outputFilePath = Path.Combine(fileDirectory, outputFileName); using (FileStream inputStream = new FileStream(path, FileMode.Open)) using (XmlReader xmlReader = XmlReader.Create(inputStream, CreateXmlReaderSettings <SubpFile>())) using (FileStream outputStream = new FileStream(outputFilePath, FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(SubpFile)); SubpFile subpFile = serializer.Deserialize(xmlReader) as SubpFile; subpFile?.Write(outputStream, encoding); } }