From 894e6b60d1de6307a72b03d0027f71962bc2e282 Mon Sep 17 00:00:00 2001 From: Alexander Schmidt Date: Thu, 13 Mar 2014 16:25:04 +0100 Subject: [PATCH] Using hashed parameter strings in cachefilenames. Unhashed parastrings are stored in first line of cachefiles and checked on open. Using hashed parameter string for cache file names. Generating parastring in seperate function. Write parastring into first line of cachefile. Checking unhashed parastring when opening cachefile. --- configcache.cpp | 23 +++++++++++++++++++++-- configcache.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/configcache.cpp b/configcache.cpp index 5987789..bdc593e 100644 --- a/configcache.cpp +++ b/configcache.cpp @@ -53,13 +53,22 @@ configcache::configcache(const string& cacheid, const int& nequi, const int& nsk refetchDataFiles = false; } +string configcache::paraString() { + stringstream parastring; + + for(int ipara=0; ipara 0 ) { + string inFileParaString; + openFileDesc = *inFileIt; if (openFileDesc.nequi < NEQUI) @@ -225,6 +236,12 @@ 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(); + } + inFiles.erase(inFileIt); if( !inFile.is_open() ) continue; @@ -299,6 +316,8 @@ void configcache::openOutFile(int actnequi) outFile.open( outFileName.str().c_str(), std::ios::binary ); + outFile << paraString() << endl; + ioBuffers->out = new boost::iostreams::filtering_ostreambuf; ioBuffers->out->push(boost::iostreams::bzip2_compressor()); ioBuffers->out->push(outFile); diff --git a/configcache.h b/configcache.h index 6054198..a7c5974 100644 --- a/configcache.h +++ b/configcache.h @@ -105,6 +105,8 @@ class configcache{ int nequileft_internal; bool doVirtualEquilibration, firstUsedConfig; + + string paraString(); }; #endif -- 2.39.5