public void DecodeTest() { bool success = WotXml.TryDecodeXml(encodedFile, out var actual, rootName: originalFile); var expected = File.ReadAllText(decodedFile); Assert.AreEqual(expected, actual); }
static int Extract(ExtractOptions opts) { if (string.IsNullOrWhiteSpace(opts.Output)) { opts.Output = opts.File; } return(WotPkg.TryExtractFile(opts.Input, opts.File, (Stream stream) => { Directory.CreateDirectory(Path.GetDirectoryName(opts.Output)); if (opts.Decode) { if (WotXml.TryDecodeXml(opts.File, stream, out var decodedXml)) { File.WriteAllText(opts.Output, decodedXml); } } else { using (var fileStream = File.OpenWrite(opts.Output)) { stream.CopyTo(fileStream); } } }) ? 0 : 1); }
private void FetchDecodedXml(Stream stream) { if (!WotXml.TryDecodeXml(StylesListXmlPath, stream, out DecodedXml)) { throw new Exception("Failed to decode styles list"); } ListXMLDocument.LoadXml(DecodedXml); }
public void NewReaderTest() { bool success = WotXml.TryDecodeXml(encodedFile, out var expected, rootName: originalFile); using (var reader = new PackedXml.PackedXmlReader(encodedFile, originalFile)) { var actual = reader.Decode(); Assert.AreEqual(expected, actual); } }
static int XmlDecode(XmlDecodeOptions opts) { if (string.IsNullOrWhiteSpace(opts.Output)) { opts.Output = opts.Input; } if (WotXml.TryDecodeXml(opts.Input, out var decodedXml)) { File.WriteAllText(opts.Output, decodedXml); return(0); } else { throw new Exception("Failed to decode xml"); } }