return NULL;
}
-bool configcache::readConfig(vector<unsigned long> *excludeFileHashes)
-{
- if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return false;
+/* returns number of equilibration-steps left */
+int configcache::readConfig(vector<unsigned long> *excludeFileHashes)
+{
+ int nequileft = NEQUI;
+
+ if(DATADIR == "" || MODE == CACHE_MODE_DISABLED) return nequileft;
if(refetchDataFiles){
refetchDataFiles = false;
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;
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;
~configcache();
configcache(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, char **configmem, const int& configMemSize,
const int& cachemode=CACHE_MODE_FULL, writeout *out_a=NULL);
- bool readConfig(vector<unsigned long> *excludeFileHashes=NULL);
+ int readConfig(vector<unsigned long> *excludeFileHashes=NULL);
void writeConfig();
void addPara(const string& parid, const double& val=0);
void setPara(const string& parid, const double& value);
return dressedfile.substr(dressedfile.find_last_of("\\/")+1);
}
-bool hypercache::readC() {
- bool readret;
+int hypercache::readC() {
+ int readret;
- if ( readret = C->readConfig(&parentConfigs) )
+ readret = C->readConfig(&parentConfigs);
+
+ if ( readret == -1 )
activeCFile = fileOfPath(C->getInFileName());
else
activeCFile = "";
O->writeConfig();
}
-bool hypercache::readO() {
- bool readret;
+int hypercache::readO() {
+ int readret;
+
+ readret = O->readConfig();
- if ( readret = O->readConfig() ) {
+ if ( readret == -1 ) {
unsigned long *parentconfig = (unsigned long*)O->getHeader("concurrent_cfile");
if ( parentconfig != NULL )
addParentConfig(parentconfig);
}
-
+
return readret;
}
static void addPara(const string& parid, const double& val=0);
static void setPara(const string& parid, const double& value);
- static bool readO();
- static bool readC();
+ static int readO();
+ static int readC();
static void writeO();
static void writeC();
static void writeHeaderO(const string& headerid, char *header, long unsigned int size) { O->writeHeader(headerid, header, size); }