public static GGValue Parse(string content) { using (var ms = new MemoryStream()) { var writer = new StreamWriter(ms); writer.Write(content); writer.Flush(); ms.Position = 0; var parser = new GGParser(ms); return(parser.ParseValue()); } }
public GGPackWriter WriteFile(string path) { var filename = Path.GetFileName(path); using (var fs = File.OpenRead(path)) { if (string.Equals(Path.GetExtension(filename), ".nut", StringComparison.OrdinalIgnoreCase)) { filename = Path.ChangeExtension(filename, ".bnut"); } var hash = new GGHash { { "filename", new GGLiteral(filename) }, { "offset", new GGLiteral(_offset) }, { "size", new GGLiteral((int)fs.Length) }, }; _gFiles.Add(hash); _offset += (int)fs.Length; } var data = File.ReadAllBytes(path); if (string.Equals(Path.GetExtension(filename), ".nut", StringComparison.OrdinalIgnoreCase)) { GGPack.DecryptBnut(data); } else if (string.Equals(Path.GetExtension(filename), ".wimpy", StringComparison.OrdinalIgnoreCase)) { GGHash hash; using (var ms = new MemoryStream(data)) { var parser = new GGParser(ms); hash = parser.ParseHash(); } using (var ms = new MemoryStream()) { using (var writer = new GGBinaryWriter(new BinaryWriter(ms))) { hash.WriteTo(writer); } data = ms.ToArray(); } } GGBinaryReader.EncodeUnbreakableXor(data); _bw.Write(data); return(this); }