X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/b80a3fda9209144605a6306ba24ec2051d387f50..2941710185479c3748e991a3932c4af8832204a9:/hypercache.cpp?ds=inline diff --git a/hypercache.cpp b/hypercache.cpp index 16de2a2..2d38b21 100644 --- a/hypercache.cpp +++ b/hypercache.cpp @@ -5,7 +5,7 @@ configcache *hypercache::C = NULL; vector hypercache::delayedParaAdd; vector hypercache::delayedParaSet; string hypercache::activeCFile = ""; -vector hypercache::parentConfigs; +vector hypercache::parentConfigs; writeout *hypercache::out = NULL; void hypercache::initCache(configcache **cache, @@ -71,10 +71,12 @@ string hypercache::fileOfPath(const string& dressedfile) { 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 = ""; @@ -88,28 +90,32 @@ void hypercache::writeC() { } void hypercache::writeO() { - if ( activeCFile != "" ) - O->writeHeader("concurrent_cfile", activeCFile.c_str(), (activeCFile.length()+1)*sizeof(char)); + if ( activeCFile != "" ) { + unsigned long afilehash = configcache::hash(activeCFile); + O->writeHeader("concurrent_cfile", (char*)(&afilehash), sizeof(unsigned long)); + } O->writeConfig(); } -bool hypercache::readO() { - bool readret; +int hypercache::readO() { + int readret; + + readret = O->readConfig(); - if ( readret = O->readConfig() ) { - char *parentconfig = (char*)O->getHeader("concurrent_cfile"); + if ( readret == -1 ) { + unsigned long *parentconfig = (unsigned long*)O->getHeader("concurrent_cfile"); if ( parentconfig != NULL ) addParentConfig(parentconfig); } - + return readret; } -void hypercache::addParentConfig(const char* parentconfig) { - for (vector::iterator parit = parentConfigs.begin(); parit != parentConfigs.end(); ++parit) - if ( *parit == parentconfig ) +void hypercache::addParentConfig(const unsigned long *parentconfig) { + for (vector::iterator parit = parentConfigs.begin(); parit != parentConfigs.end(); ++parit) + if ( *parit == *parentconfig ) return; - parentConfigs.push_back(parentconfig); + parentConfigs.push_back(*parentconfig); }