int BDATreader::open(string fn,bool makeTOC) { if(state==0) { char FID[8]; unsigned int BOM; if(fn.length()>0) filename=fn; f=FileOpen(filename,fmOpenRead); if(f<0) return -2; size=FileSize(f); pos=0; FileRead(f,FID,4);FID[4]=0;pos+=4; FileRead(f,&BOM,4);pos+=4; if(string(FID)!="BDAT") return -3; //check for endian encoding of file data - not implemented/used switch (BOM) { case 0xFEFF: endian=0; //match break; default: endian=-1; break; } if(makeTOC) createTOC(); state=1; lastinfo.records=0; } else return -1; return 0; };
void DocumentationPlugin::reload() { clear(); for (QValueList<DocumentationCatalogItem *>::iterator it = catalogs.begin(); it != catalogs.end(); ++it) { createTOC(*it); } }
int BDATreader::seek(unsigned int ID,datablockinfo &db) { int n=0; if(!hasTOC) createTOC(); if(!hasTOC) return -1; //no TOC available (empty file?) while((n<TOCN) && (TOCID[n]!=ID)) n++; if(n==TOCN) return -2; //entry not found pos=TOCpos[n];state=1; FileSeek(f,pos,SEEK_SET); return getnextblockinfo(db); };