+bool configcache::openInFile() {
+ while( (!inFile.is_open()) && inFiles.size() > 0 )
+ {
+ if(out) *out->log << "CCACHE: Opening dat-file: " << inFiles.back().filename << endl << flush;
+
+ openFileDesc = inFiles.back();
+ inFile.open( (DATADIR + "/" + inFiles.back().filename).c_str(), std::ios::binary );
+ inFiles.pop_back();
+
+ if( !inFile.is_open() ) continue;
+
+ inBuffer = new boost::iostreams::filtering_istreambuf;
+ inBuffer->push( boost::iostreams::bzip2_decompressor() );
+ inBuffer->push(inFile);
+
+ return true;
+ }
+
+ return false;
+}
+
+void configcache::readHeader()
+{
+ int headersize;
+
+ if( readDataToMem((char*)&headersize, sizeof(int)) == sizeof(int) && inFile.is_open() )
+ {
+ if( headerData != NULL ) delete headerData;
+
+ headerData = new char(headersize);
+
+ if( readDataToMem(headerData, headersize) == headersize && inFile.is_open() ) {
+ if(out) *out->log << "CCACHE: Read header information." << endl << flush;
+ }
+ else {
+ if(out) *out->log << "CCACHE: Could not read header! Closing dat-file: " << openFileDesc.filename << endl << flush;
+ inFile.close();
+ }
+ }
+ else {
+ if(out) *out->log << "CCACHE: Could not read header size! Closing dat-file: " << openFileDesc.filename << endl << flush;
+ inFile.close();
+ }
+}
+
+void *configcache::getHeader() {
+ return headerData;
+}
+