| 415 | } |
| 416 | |
| 417 | bool TinyDictIndexFile::open( const char * filename ) |
| 418 | { |
| 419 | close(); |
| 420 | if ( filename ) |
| 421 | setFilename( filename ); |
| 422 | if ( !fname ) |
| 423 | return false; |
| 424 | f = fopen( fname, "rb" ); |
| 425 | if ( !f ) |
| 426 | return false; |
| 427 | if ( fseek( f, 0, SEEK_END ) ) { |
| 428 | close(); |
| 429 | return false; |
| 430 | } |
| 431 | size = ftell( f ); |
| 432 | if ( fseek( f, 0, SEEK_SET ) ) { |
| 433 | close(); |
| 434 | return false; |
| 435 | } |
| 436 | // test |
| 437 | TinyDictWord * p; |
| 438 | count = 0; |
| 439 | for ( ;; count++ ) { |
| 440 | p = TinyDictWord::read( f, count ); |
| 441 | if ( !p ) |
| 442 | break; |
| 443 | if ( (count % factor) == 0 ) { |
| 444 | list.add( p ); |
| 445 | } else { |
| 446 | delete p; |
| 447 | } |
| 448 | } |
| 449 | printf("%d words read from index\n", count); |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | enum { |
| 454 | DICT_TEXT, |