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 }
int MeasureEntryLength(HeteroIdxTable tbl) { for (int cnt = 0;; ++cnt) { if (tbl.ReadByte() == 0) { return(cnt + 1 + AddressSize); // '\0' + sizeof(offsetPtr) + 4 bytes size } } }
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 }
int MeasureEntryLength(HeteroIdxTable tbl) { for (int cnt = 0;; ++cnt) { if (tbl.ReadByte() == 0) return cnt + 1 + AddressSize; // '\0' + sizeof(offsetPtr) + 4 bytes size } }