]> git.treefish.org Git - phys/latlib.git/blobdiff - configcache.cpp
Fixed unhashed fileid creation.
[phys/latlib.git] / configcache.cpp
index bdc593e3c53131ff78e3a869707a7b3c8886c7e7..59472e9c31856ca4c297945087d93b5502bdd798 100644 (file)
@@ -62,13 +62,16 @@ string configcache::paraString() {
   return parastring.str();
 }
 
   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;
 
 {
   stringstream fileid;
 
   if(!shortid) fileid << CACHEID << "_" << actnequi << "_" << NSKIP;
 
-  fileid << "_" << hash( paraString() );
+  if( superextended )
+    fileid << "_" << hash( paraString() );
+  else
+    fileid << paraString();
 
   return fileid.str();
 }
 
   return fileid.str();
 }
@@ -100,10 +103,18 @@ bool configcache::isValidInFile(const string& infile, infiledesc *filedesc)
 
   if( infile.size() < 4 ) return false;
 
 
   if( infile.size() < 4 ) return false;
 
-  if( infile.substr(infile.size()-4) == ".dat" )
+  if( infile.substr(infile.size()-4) == ".dat" ) {
     filedesc->extended = false;
     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->extended = true;
+    filedesc->superextended = false;
+  }
+  else if( infile.substr(infile.size()-4) == "sdat" ) {
+    filedesc->extended = true;
+    filedesc->superextended = true;
+  }
   else
     return false;
 
   else
     return false;
 
@@ -135,7 +146,7 @@ bool configcache::isValidInFile(const string& infile, infiledesc *filedesc)
 
   delete[] inchar;
 
 
   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;
 }
 
   return true;
 }
@@ -236,12 +247,14 @@ void configcache::readConfig(bool *readnewconfig, int *nequileft, vector<unsigne
        if(log) *log << "CCACHE: Opening dat-file: " << inFileIt->filename << endl << flush;
        inFile.open( (DATADIR + "/" + inFileIt->filename).c_str(), std::ios::binary );
        
        if(log) *log << "CCACHE: Opening dat-file: " << inFileIt->filename << 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;
        inFiles.erase(inFileIt);
        
        if( !inFile.is_open() ) continue;
@@ -298,7 +311,7 @@ void configcache::openOutFile(int actnequi)
   
   while (true) {
     outFileName.str("");
   
   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);
 
 
     int tmpfd = open(outFileName.str().c_str(), O_CREAT | O_EXCL, 0644);