示例#1
0
        public void TestDzip()
        {
            using (var dz = DictZip.OpenRead("sm_entry.csv.dz"))
            {
                Assert.AreEqual(81, dz.ExtraField.ChunkCount);
                Assert.AreEqual(58315, dz.ExtraField.ChunkSize);
//				byte[] content = File.ReadAllBytes("sm_entry.csv");
//				CollectionAssert.AreEqual(content, dz.ReadAllBytes());
                string s = "540,500,文一  重一,,,\n";
                Assert.AreEqual(s, dz.GetEntry((int)dz.OriginalSize - 26, 26));
                using (var f = File.OpenRead("sm_entry.csv"))
                    using (var dz2 = DictZip.Create("foo.dz", true))
                    {
                        dz2.Name    = "dz2";
                        dz2.Comment = "no comment";
                        dz2.Compress(f);
                    }
                using (var dz2 = DictZip.OpenRead("foo.dz"))
                {
                    Assert.AreEqual("dz2", dz2.Name);
                    Assert.AreEqual("no comment", dz2.Comment);
                    Assert.AreEqual(81, dz2.ExtraField.ChunkCount);
                    Assert.AreEqual(s, dz2.GetEntry((int)dz.OriginalSize - 26, 26));
                }
            }
        }
示例#2
0
 private StarDict(StarDictInfo info, IDictIdx index, string fileName, Encoding encoding)
 {
     this.encoding = encoding ?? Encoding.UTF8;
     this.info     = info;
     this.index    = index;
     this.database = fileName.EndsWith("dz") ? DictZip.OpenRead(fileName) : (IDictDb) new TxtDictDb(fileName);
 }