X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/0391c237272d90acfc769f4aeebe0554d47f74cb..38ffdcb3843eec92d62b23d32a735107a49fb7d8:/configcache.cpp diff --git a/configcache.cpp b/configcache.cpp index c6f9082..491256c 100644 --- a/configcache.cpp +++ b/configcache.cpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include #include @@ -50,13 +53,25 @@ configcache::configcache(const string& cacheid, const int& nequi, const int& nsk refetchDataFiles = false; } -string configcache::getFileId(int actnequi, const bool& shortid) +string configcache::paraString() { + stringstream parastring; + + for(int ipara=0; iparaextended = false; - else if( infile.substr(infile.size()-4) == "edat" ) + filedesc->superextended = false; + } + else if( infile.substr(infile.size()-4) == "edat" ) { filedesc->extended = true; + filedesc->superextended = false; + } + else if( infile.substr(infile.size()-4) == "sdat" ) { + filedesc->extended = true; + filedesc->superextended = true; + } else return false; @@ -123,7 +146,7 @@ bool configcache::isValidInFile(const string& infile, infiledesc *filedesc) delete[] inchar; - if( truncIn.find( getFileId(NEQUI, true) + "_" ) == string::npos ) return false; + if( truncIn.find( getFileId(NEQUI, filedesc->superextended, true) + "_" ) == string::npos ) return false; return true; } @@ -191,7 +214,7 @@ void configcache::readConfig(bool *readnewconfig, int *nequileft, vector 0 ) { + string inFileParaString; + openFileDesc = *inFileIt; if (openFileDesc.nequi < NEQUI) @@ -222,6 +247,14 @@ void configcache::readConfig(bool *readnewconfig, int *nequileft, vectorfilename << endl << flush; inFile.open( (DATADIR + "/" + inFileIt->filename).c_str(), std::ios::binary ); + if( openFileDesc.superextended ) { + getline( inFile, inFileParaString ); + if( inFileParaString != paraString() ) { + if(log) *log << "CCACHE: Parastring does not match. Closing dat-file..." << endl << flush; + inFile.close(); + } + } + inFiles.erase(inFileIt); if( !inFile.is_open() ) continue; @@ -274,12 +307,30 @@ void configcache::readConfig(bool *readnewconfig, int *nequileft, vectorout = new boost::iostreams::filtering_ostreambuf; ioBuffers->out->push(boost::iostreams::bzip2_compressor()); ioBuffers->out->push(outFile); @@ -288,7 +339,7 @@ void configcache::openOutFile(int actnequi) void configcache::writeHeader(const string& headerid, const char *header, long unsigned int size, int actnequi) { unsigned long headeridhash; - if( DATADIR == "" || MODE < 2 ) return; + if( DATADIR == "" || !(MODE==CACHE_MODE_WO||MODE==CACHE_MODE_RW) ) return; if(!outFile.is_open()) openOutFile(actnequi); @@ -304,7 +355,7 @@ void configcache::writeConfig(int actnequi) { long unsigned int zeroheader=0; - if ( DATADIR == "" || MODE < 2 ) return; + if ( DATADIR == "" || !(MODE==CACHE_MODE_WO||MODE==CACHE_MODE_RW) ) return; if ( ! outFile.is_open() ) openOutFile(actnequi);