X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/c1fa6a1beca0ee805fd717b65ab4e959c5864950..ad54f29de351976a096b4991fe426ffc30332df2:/configcache.cpp diff --git a/configcache.cpp b/configcache.cpp index d45e4d6..6cd46a1 100644 --- a/configcache.cpp +++ b/configcache.cpp @@ -186,28 +186,17 @@ int configcache::readConfig(vector *excludeFileHashes) while(true) { - if( (!inFile.is_open()) && inFiles.size() == 0 ) return nequileft; + vector::iterator inFileIt = getNextInfile(excludeFileHashes); - while( (!inFile.is_open()) && inFiles.size() > 0 ) { - bool excludethisfile=false; + if( (!inFile.is_open()) && inFileIt == inFiles.end() ) return nequileft; - openFileDesc = inFiles.back(); + while( (!inFile.is_open()) && inFiles.size() > 0 ) { + openFileDesc = *inFileIt; - if (excludeFileHashes != NULL) - for (vector::iterator exit = excludeFileHashes->begin(); exit != excludeFileHashes->end(); ++exit) - if ( *exit == hash(inFiles.back().filename) ) { - excludethisfile = true; - break; - } - - if ( ! excludethisfile ) { - if(log) *log << "CCACHE: Opening dat-file: " << inFiles.back().filename << endl << flush; - inFile.open( (DATADIR + "/" + inFiles.back().filename).c_str(), std::ios::binary ); - } - else - if(log) *log << "CCACHE: Excluded dat-file: " << inFiles.back().filename << endl << flush; + if(log) *log << "CCACHE: Opening dat-file: " << inFileIt->filename << endl << flush; + inFile.open( (DATADIR + "/" + inFileIt->filename).c_str(), std::ios::binary ); - inFiles.pop_back(); + inFiles.erase(inFileIt); if( !inFile.is_open() ) continue; @@ -382,3 +371,22 @@ void configcache::deleteHeaderStore() headerStore.pop_back(); } } + +vector::iterator configcache::getNextInfile(vector *excludeFileHashes) { + for (vector::iterator init = inFiles.begin(); init != inFiles.end(); ++init) { + if (excludeFileHashes != NULL) { + bool excludethisfile = false; + + for (vector::iterator exit = excludeFileHashes->begin(); exit != excludeFileHashes->end(); ++exit) + if ( *exit == hash(init->filename) ) { + excludethisfile = true; + break; + } + + if (excludethisfile) + continue; + } + return init; + } + return inFiles.end(); +}