Lines Matching refs:fp
112 bool DictTrie::save_dict(FILE *fp) {
113 if (NULL == fp)
116 if (fwrite(&lma_node_num_le0_, sizeof(size_t), 1, fp) != 1)
119 if (fwrite(&lma_node_num_ge1_, sizeof(size_t), 1, fp) != 1)
122 if (fwrite(&lma_idx_buf_len_, sizeof(size_t), 1, fp) != 1)
125 if (fwrite(&top_lmas_num_, sizeof(size_t), 1, fp) != 1)
128 if (fwrite(root_, sizeof(LmaNodeLE0), lma_node_num_le0_, fp)
132 if (fwrite(nodes_ge1_, sizeof(LmaNodeGE1), lma_node_num_ge1_, fp)
136 if (fwrite(lma_idx_buf_, sizeof(unsigned char), lma_idx_buf_len_, fp) !=
153 FILE *fp = fopen(filename, "wb");
154 if (NULL == fp)
157 if (!spl_trie.save_spl_trie(fp) || !dict_list_->save_list(fp) ||
158 !save_dict(fp) || !ngram.save_ngram(fp)) {
159 fclose(fp);
163 fclose(fp);
168 bool DictTrie::load_dict(FILE *fp) {
169 if (NULL == fp)
172 if (fread(&lma_node_num_le0_, sizeof(size_t), 1, fp) != 1)
175 if (fread(&lma_node_num_ge1_, sizeof(size_t), 1, fp) != 1)
178 if (fread(&lma_idx_buf_len_, sizeof(size_t), 1, fp) != 1)
181 if (fread(&top_lmas_num_, sizeof(size_t), 1, fp) != 1 ||
210 if (fread(root_, sizeof(LmaNodeLE0), lma_node_num_le0_, fp)
214 if (fread(nodes_ge1_, sizeof(LmaNodeGE1), lma_node_num_ge1_, fp)
218 if (fread(lma_idx_buf_, sizeof(unsigned char), lma_idx_buf_len_, fp) !=
249 FILE *fp = fopen(filename, "rb");
250 if (NULL == fp)
257 fclose(fp);
264 if (!spl_trie.load_spl_trie(fp) || !dict_list_->load_list(fp) ||
265 !load_dict(fp) || !ngram.load_ngram(fp) ||
268 fclose(fp);
272 fclose(fp);
282 FILE *fp = fdopen(sys_fd, "rb");
283 if (NULL == fp)
286 if (-1 == fseek(fp, start_offset, SEEK_SET)) {
287 fclose(fp);
295 fclose(fp);
302 if (!spl_trie.load_spl_trie(fp) || !dict_list_->load_list(fp) ||
303 !load_dict(fp) || !ngram.load_ngram(fp) ||
304 ftell(fp) < start_offset + length ||
307 fclose(fp);
311 fclose(fp);