MCPcopy Create free account
hub / github.com/buggins/coolreader / open

Method open

tinydict/tinydict.cpp:417–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417bool 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
453enum {
454 DICT_TEXT,

Callers 2

addMethod · 0.45
mainFunction · 0.45

Calls 5

updateMethod · 0.65
addMethod · 0.45
resetMethod · 0.45
getMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected