From e34773ccb43eefc86dc814b768af85da2873e5ef Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Thu, 13 Mar 2014 22:16:21 +0100 Subject: [PATCH] Changed hashed parastring cachfilename postfix to sdat and made configcache backward compatible to old edat format. --- configcache.cpp | 35 ++++++++++++++++++++++++----------- configcache.h | 3 ++- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/configcache.cpp b/configcache.cpp index bdc593e..491256c 100644 --- a/configcache.cpp +++ b/configcache.cpp @@ -62,13 +62,16 @@ string configcache::paraString() { return parastring.str(); } -string configcache::getFileId(int actnequi, const bool& shortid) +string configcache::getFileId(int actnequi, const bool& superextended, const bool& shortid) { stringstream fileid; if(!shortid) fileid << CACHEID << "_" << actnequi << "_" << NSKIP; - fileid << "_" << hash( paraString() ); + if( superextended ) + fileid << "_" << hash( paraString() ); + else + fileid << "_" << paraString(); return fileid.str(); } @@ -100,10 +103,18 @@ bool configcache::isValidInFile(const string& infile, infiledesc *filedesc) if( infile.size() < 4 ) return false; - if( infile.substr(infile.size()-4) == ".dat" ) + if( infile.substr(infile.size()-4) == ".dat" ) { filedesc->extended = 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; @@ -135,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; } @@ -236,12 +247,14 @@ void configcache::readConfig(bool *readnewconfig, int *nequileft, vectorfilename << endl << flush; inFile.open( (DATADIR + "/" + inFileIt->filename).c_str(), std::ios::binary ); - getline( inFile, inFileParaString ); - if( inFileParaString != paraString() ) { - if(log) *log << "CCACHE: Parastring does not match. Closing dat-file..." << endl << flush; - inFile.close(); + 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; @@ -298,7 +311,7 @@ void configcache::openOutFile(int actnequi) while (true) { outFileName.str(""); - outFileName << DATADIR << "/" << secstamp << "." << iseq << "_" << getFileId(actnequi) << "_.edat.tmp"; + outFileName << DATADIR << "/" << secstamp << "." << iseq << "_" << getFileId(actnequi, true, false) << "_.sdat.tmp"; int tmpfd = open(outFileName.str().c_str(), O_CREAT | O_EXCL, 0644); diff --git a/configcache.h b/configcache.h index a7c5974..d07aea4 100644 --- a/configcache.h +++ b/configcache.h @@ -24,6 +24,7 @@ struct infiledesc { int nequi; int nskip; bool extended; + bool superextended; }; class configcache{ @@ -59,7 +60,7 @@ class configcache{ string DATADIR; string CACHEID; int MODE; - string getFileId(int actnequi, const bool& shortid=false); + string getFileId(int actnequi, const bool& superextended=true, const bool& shortid=false); ofstream outFile; ifstream inFile; -- 2.39.5