137 DEFAULT_ENCODING), |
137 DEFAULT_ENCODING), |
138 cpix_STORE_NO | cpix_INDEX_TOKENIZED)); |
138 cpix_STORE_NO | cpix_INDEX_TOKENIZED)); |
139 doc->add(newField.get()); |
139 doc->add(newField.get()); |
140 newField.release(); |
140 newField.release(); |
141 |
141 |
142 wchar_t |
142 /* determine file size. if the stream is not seekable, the size will be -1 |
143 excerpt[512]; |
143 * Here if the file is empty then we put the path name contained in |
144 getExcerptOfFile(excerpt, |
144 * "_docuid" as excerpt |
|
145 */ |
|
146 FILE* textFilePtr = fopen(path, "r"); |
|
147 fseek(textFilePtr, 0, SEEK_END); |
|
148 long long size = ftell(textFilePtr); |
|
149 fseek(textFilePtr, 0, SEEK_SET); |
|
150 fclose(textFilePtr); |
|
151 if (size > 0) { |
|
152 wchar_t excerpt[512]; |
|
153 getExcerptOfFile(excerpt, |
145 path, |
154 path, |
146 10, // max words |
155 10, // max words |
147 sizeof(excerpt) / sizeof(wchar_t)); |
156 sizeof(excerpt) / sizeof(wchar_t)); |
148 |
157 doc->setExcerpt(excerpt); |
149 doc->setExcerpt(excerpt); |
158 |
150 doc->setAppClass(TEXTAPPCLASS); |
159 } else { |
|
160 //For empty file setting the path as excerpt |
|
161 doc->setExcerpt(doc->get(LCPIX_DOCUID_FIELD)); |
|
162 } |
|
163 doc->setAppClass(CONTENTAPPCLASS); |
151 doc->setMimeType(LTEXTFILE_MIMETYPE); |
164 doc->setMimeType(LTEXTFILE_MIMETYPE); |
152 // Always perform generic file processing |
165 // Always perform generic file processing |
153 GenericFileProcessor(doc,path); |
166 GenericFileProcessor(doc,path); |
154 |
167 |
155 |
168 |