X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/7f5403eed95da4350dcc03d817eb8468dab07142..f2373be314dc298d602b1939cde3d5ae990dd07f:/configcache.cpp?ds=sidebyside diff --git a/configcache.cpp b/configcache.cpp index 1095775..a3490ad 100644 --- a/configcache.cpp +++ b/configcache.cpp @@ -172,9 +172,12 @@ void * configcache::getHeader(const string& headerid) { return NULL; } -bool configcache::readConfig(vector *excludeFileHashes) -{ - if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return false; +/* returns number of equilibration-steps left */ +int configcache::readConfig(vector *excludeFileHashes) +{ + int nequileft = NEQUI; + + if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return nequileft; if(refetchDataFiles){ refetchDataFiles = false; @@ -183,7 +186,7 @@ bool configcache::readConfig(vector *excludeFileHashes) while(true) { - if( (!inFile.is_open()) && inFiles.size() == 0 ) return false; + if( (!inFile.is_open()) && inFiles.size() == 0 ) return nequileft; while( (!inFile.is_open()) && inFiles.size() > 0 ) { bool excludethisfile=false; @@ -221,13 +224,17 @@ bool configcache::readConfig(vector *excludeFileHashes) for (int iskip=0; iskip < (NEQUI-openFileDesc.nequi)/openFileDesc.nskip; iskip++) { if( readFullBlock(tmpConfig, configSize) != configSize || ! inFile.is_open() ) break; + else if ( (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip < nequileft ) { + memcpy(configMem, tmpConfig, configSize); + nequileft = (NEQUI-openFileDesc.nequi) - (iskip+1)*openFileDesc.nskip; + } } } if( readFullBlock(tmpConfig, configSize) == configSize && inFile.is_open() ) { memcpy(configMem, tmpConfig, configSize); - return true; + return -1; } else { if(out) *out->log << "CCACHE: Could not read configuration. Closing dat-file: " << openFileDesc.filename << endl << flush;