unsigned int FSManager::findFatBlock() { stringstream debug; debug << "Wchodze do findFatBlock() \n"; printDEBUG(debug); Block FATBlock; if (!diskFile.is_open()) { std::cout << "diskFile nie otwarty w findFatBlock()!\n"; cout << "fail: " << diskFile.fail(); cout << "eof: " << diskFile.eof(); return 0; } diskFile.seekg(sizeof (DiskInfo)); debug << "Ustawiam seekg na " << diskFile.tellg() << "\n"; printDEBUG(debug); while (1) { debug << "Wchodze do petli while(1) w findFatBlock\n"; debug << "Czytam z pozycji " << diskFile.tellg() << "\n"; printDEBUG(debug); diskFile.read((char *) & FATBlock, sizeof (FATBlock)); if (diskFile.fail() || diskFile.eof()) { std::cout << "fail albo eof w findFatBlock()\n"; cout << "fail: " << diskFile.fail() << std::endl; cout << "eof: " << diskFile.eof() << std::endl; cout << "findFatBlock next: " << FATBlock.next << std::endl; return 0; } if (FATBlock.size < (blkSize - sizeof (FileInfo) - sizeof (Block))) { cout << "jeden fat wystarcza do zapisu... : " << FATBlock.current << "\n"; return FATBlock.current; } if (FATBlock.next == 0) { diskFile.seekp(FATBlock.current * blkSize + sizeof (DiskInfo)); break; } else diskFile.seekg(blkSize * FATBlock.next + sizeof (DiskInfo)); } cout << "jeden fat nie wystarczyl\n"; this->freeSpace -= sizeof (blkSize); FATBlock.next = this->findFreeBlock(); cout << "nastepny: " << FATBlock.next << "\n"; diskFile.write((char*) & FATBlock, sizeof (FATBlock)); diskFile.seekp(FATBlock.next * blkSize + sizeof (DiskInfo)); FATBlock.current = FATBlock.next; FATBlock.next = 0; FATBlock.size = 0; diskFile.write((char*) & FATBlock, sizeof (FATBlock)); return FATBlock.current; }
FILE *smfPrintStart(FILE *fp, char *name, void *p, size_t l, BOOL *f, BOOL *newFile,columnHeader_t **h) { FILE *fpNew = fp; BOOL first = *f; int i; offsetH=0; offsetD=0; columnCount=0; tableName = name; columnHeadersTmp = h; localFirst = first; /* Dump the entire record in hex */ if (debugLevel >=1 ) { printDEBUG(name,p,(l)); } if (first) { switch (outputFormat) { case OF_CSV: case OF_SQL: fpNew = fopencsv(name,newFile); if (outputFormat == OF_SQL) openDDL(name); if (!fpNew) { exit(1); } break; case OF_JSON: if (!fpNew) { fpNew = fopenext("MQSMF","json",newFile); if (!fpNew) { exit(1); } } break; } for(i=0;i<HEADINGS_COUNT;i++) { h[i] = 0; } } if (outputFormat == OF_JSON) jsonNew(fpNew,name); ADDSTR ("Date",commonF.recordDate,8); ADDSTR ("Time",commonF.recordTime,16); ADDSTRN("LPAR",commonF.systemId,4,4); ADDSTRN("QMgr",commonF.qMgr,4,4); ADDSTRN("MQ_Version",commonF.mqVer,3,3); if (recordType == 115 && commonF.intstart != 0) { char *dt[2]; unsigned long long du = conv64(commonF.intduration)/1000000L; ADDTIME("Interval_Start",commonF.intstart); ADDHEAD("Interval_Duration",DDL_I,0); /* Not documented, but this subtype uses a different scale for */ /* measuring the duration. */ if (recordSubType == 231) { ADDDATA(ODT_I64,"%llu,",du/4096L); } else { ADDDATA(ODT_I64,"%llu,",du); } } *f = first; return fpNew; }