public string SaveToString() { var json = new MyJson.JsonNode_Object(); json.SetDictValue("script", script.ToJson()); if (string.IsNullOrEmpty(error) == false) { json.SetDictValue("error", error); } json.SetDictValue("VMState", state.ToString()); StringBuilder sb = new StringBuilder(); json.ConvertToStringWithFormat(sb, 0); var jsontxt = sb.ToString(); byte[] data = System.Text.Encoding.UTF8.GetBytes(jsontxt); var ms = new System.IO.MemoryStream(data); var bts = llvm.QuickFile.ToBytes(ms); return(bts.ToHexString()); }
public void Save(string filename) { var path = System.IO.Path.GetDirectoryName(filename); if (System.IO.Directory.Exists(path) == false) { System.IO.Directory.CreateDirectory(path); } System.IO.File.Delete(filename + ".json"); System.IO.File.Delete(filename); var json = new MyJson.JsonNode_Object(); json.SetDictValue("script", script.ToJson()); if (string.IsNullOrEmpty(error) == false) { json.SetDictValue("error", error); } json.SetDictValue("VMState", state.ToString()); StringBuilder sb = new StringBuilder(); json.ConvertToStringWithFormat(sb, 0); System.IO.File.WriteAllText(filename, sb.ToString()); var bts = llvm.QuickFile.ToBytes(filename); //var compressor = new SevenZip.SevenZipCompressor(); //compressor.CompressionMethod = SevenZip.CompressionMethod.Lzma; //compressor.CompressionLevel = SevenZip.CompressionLevel.Fast; //compressor.FastCompression = true; ////compressor.path = path; //compressor.CompressFiles(filename, System.IO.Path.GetFullPath(filename + ".json")); System.IO.File.WriteAllText(filename, bts.ToHexString()); System.IO.File.Delete(filename + ".json"); }