Пример #1
0
 public static void SaveTnt(IReadOnlyMapModel map, string filename)
 {
     using (var s = new TntWriter(File.Create(filename)))
     {
         s.WriteTnt(new MapModelTntAdapter(map));
     }
 }
Пример #2
0
        public static void SaveHpi(IReadOnlyMapModel map, string filename)
        {
            var namePart = Path.GetFileNameWithoutExtension(filename);

            var tmpTntName = Path.GetTempFileName();
            var tmpOtaName = Path.GetTempFileName();

            try
            {
                using (var s = new TntWriter(File.Create(tmpTntName)))
                {
                    s.WriteTnt(new MapModelTntAdapter(map));
                }

                using (Stream s = File.Create(tmpOtaName))
                {
                    map.Attributes.WriteOta(s);
                }

                var fname = "maps\\" + namePart;

                using (var wr = new HpiWriter(filename, HpiWriter.CompressionMethod.ZLib))
                {
                    wr.AddFile(fname + ".tnt", tmpTntName);
                    wr.AddFile(fname + ".ota", tmpOtaName);
                }
            }
            finally
            {
                if (File.Exists(tmpTntName))
                {
                    File.Delete(tmpTntName);
                }

                if (File.Exists(tmpOtaName))
                {
                    File.Delete(tmpOtaName);
                }
            }
        }