示例#1
0
        public StarDictIdx(StarDictInfo info, Encoding enc = null)
        {
            _enc        = enc ?? Encoding.UTF8;
            _offsetSize = info.PointerSize;
            _nEntries   = info.NumberOfEntries;

            string fname = info.BaseName + ".idx";

            if (File.Exists(fname))
            {
                _table = new TxtHeteroIdxTable(fname, MeasureEntryLength);
            }
            else
            {
                _table = new StrHeteroIdxTable(fname + ".gz", MeasureEntryLength);
            }

            //create and populate the index of index
            _idxIdx = new int[_nEntries + 1];
            for (int cnt = 1, offset = 0; cnt < _nEntries; ++cnt)
            {
                _idxIdx[cnt] = offset = _table.FindNext(offset);
            }
            _idxIdx[_nEntries] = info.IndexFileSize;            //last sentry
        }
示例#2
0
 int MeasureEntryLength(HeteroIdxTable tbl)
 {
     for (int cnt = 0;; ++cnt)
     {
         if (tbl.ReadByte() == 0)
         {
             return(cnt + 1 + AddressSize);                    // '\0' + sizeof(offsetPtr) + 4 bytes size
         }
     }
 }
示例#3
0
        public StarDictIdx(StarDictInfo info, Encoding enc = null)
        {
            _enc = enc ?? Encoding.UTF8;
            _offsetSize = info.PointerSize;
            _nEntries = info.NumberOfEntries;

            string fname = info.BaseName + ".idx";
            if (File.Exists(fname))
                _table = new TxtHeteroIdxTable(fname, MeasureEntryLength);
            else
                _table = new StrHeteroIdxTable(fname + ".gz", MeasureEntryLength);

            //create and populate the index of index
            _idxIdx = new int[_nEntries + 1];
            for (int cnt = 1, offset = 0; cnt < _nEntries; ++cnt)
            {
                _idxIdx[cnt] = offset = _table.FindNext(offset);
            }
            _idxIdx[_nEntries] = info.IndexFileSize;//last sentry
        }
示例#4
0
 int MeasureEntryLength(HeteroIdxTable tbl)
 {
     for (int cnt = 0;; ++cnt)
     {
         if (tbl.ReadByte() == 0)
             return cnt + 1 + AddressSize; // '\0' + sizeof(offsetPtr) + 4 bytes size
     }
 }