void TestWinText(void) { BeginTests(); ObjectsInit(); CWinText cWinText; SWinFontInstance* psWinFont; Ptr<CFont> pcFont; CGlyph* pcCel; CImage cDestImage; cWinText.Init(NULL); psWinFont = cWinText.Create("Fixedsys", 0, 0, FW_DONTCARE); pcFont = cWinText.GenerateFont(psWinFont, "Fixedsys"); WriteImage(&pcFont->GetImage(), "Output/Fixedsys.bmp"); AssertFile("Input/Fixedsys.bmp", "Output/Fixedsys.bmp"); pcCel = pcFont->GetGlyph('H'); pcCel->GetSubImage()->SetAlignment(SUB_IMAGE_ALIGNMENT_LEFT|SUB_IMAGE_ALIGNMENT_TOP); cDestImage.Init(pcCel->GetFullWidth(), pcCel->GetFullHeight(), pcCel->GetSourceImage()); cDestImage.Clear(); CImageCopier::Copy(pcCel->GetCel(), &cDestImage, 0, 0); WriteImage(&cDestImage, "Output/TheLetterH.png"); cDestImage.Kill(); AssertFile("Input/TheLetterH.png", "Output/TheLetterH.png"); pcFont->Kill(); cWinText.Kill(); ObjectsKill(); TestStatistics(); }
bool KItemCreate::_LoadCreateInfo(T_MAP& mapCreateInfo, const char* pFileName) { KTabfileLoader& loader = KTabfileLoader::GetInstance(); KTabFile2* pTF2 = loader.GetFileReader(pFileName); if(NULL == pTF2) { AssertFile(pFileName); return false; } KTabFile2& ItemTabFile = *pTF2; INT i = 0; while (true) { i++; int nRet = ItemTabFile.ReadLine(); if(nRet == -1) { loader.CloseFileReader(pTF2); AssertFile(pFileName); return false; } if(nRet == 0) break; typename T_MAP::value_type item; //T_CreateInfo item; int nID = _LoadItemInfo(ItemTabFile, item); if(nID < 0) { Log(LOG_ERROR, "错误的物品ID:%s第%d行错误.", pFileName, i); continue; } if(mapCreateInfo.end() == mapCreateInfo.insert(nID, item)) { Log(LOG_ERROR, "Item initilaze error, item id[%d] duplicate insert", nID); continue; } } loader.CloseFileReader(pTF2); printf("文件[%s]读取记录[%d]条。\n", pFileName, mapCreateInfo.size()); return true; }
// Code int GetRsfSettings(user_settings *set) { int ret = 0; if(set->common.rsfPath) { if(!AssertFile(set->common.rsfPath)) { fprintf(stderr,"[RSF ERROR] Failed to open %s\n",set->common.rsfPath); return FAILED_TO_OPEN_FILE; } ret = ParseSpecFile(&set->common.rsfSet,set->common.rsfPath, &set->dname); } return ret; }
void TestObjectsFlushNoClear(void) { CFileUtil cFileUtil; BOOL bResult; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/Flush1"); ObjectsInit("Output/Flush1"); SetupObjectsForDehollowfication(); AssertLongLongInt(0, gcObjects.NumDatabaseObjects()); AssertLongLongInt(0, gcObjects.NumDatabaseNames()); AssertLongLongInt(9, gcObjects.NumMemoryIndexes()); AssertLongLongInt(6, gcObjects.NumMemoryNames()); bResult = gcObjects.Flush(FALSE, FALSE); AssertTrue(bResult); AssertLongLongInt(9, gcObjects.NumDatabaseObjects()); AssertLongLongInt(6, gcObjects.NumDatabaseNames()); AssertLongLongInt(9, gcObjects.NumMemoryIndexes()); AssertLongLongInt(6, gcObjects.NumMemoryNames()); ObjectsKill(); CArrayChars aszFileNames; int i; CChars* psz; CChars szOutput; CChars szFileName; aszFileNames.Init(); cFileUtil.FindAllFiles("Input/Dehollowfication", &aszFileNames, FALSE, FALSE); for (i = 0; i < aszFileNames.NumElements(); i++) { psz = aszFileNames.Get(i); szFileName.Init(psz->Text()); cFileUtil.RemovePath(&szFileName); szOutput.Init(); cFileUtil.CurrentDirectory(&szOutput); cFileUtil.AppendToPath(&szOutput, "Output/Flush1"); cFileUtil.AppendToPath(&szOutput, szFileName.Text()); AssertFile(psz->Text(), szOutput.Text()); szOutput.Kill(); szFileName.Kill(); } aszFileNames.Kill(); }
void TestPackFilesPackerSimple(void) { CFileUtil cFileUtil; CPackFilePacker cPacker; cFileUtil.RemoveDir("Output/Packer"); cFileUtil.MakeDir("Output/Packer"); cFileUtil.MakeDir("Output/Packer/Sounds"); cPacker.Pack("Output/Packer/Sounds/Cheese.PAK", "Input/Game/PAK/Cheese"); AssertFile("Game/Sounds/Cheese.PAK", "Output/Packer/Sounds/Cheese.PAK"); cPacker.Pack("Output/Packer/Sounds/Santa.PAK", "Input/Game/PAK/Santa"); AssertFile("Game/Sounds/Santa.PAK", "Output/Packer/Sounds/Santa.PAK"); cPacker.Pack("Output/Packer/Models.PAK", "Input/Game/PAK/Models"); AssertFile("Game/Models.PAK", "Output/Packer/Models.PAK"); cPacker.Pack("Output/Packer/Sounds.PAK", "Input/Game/PAK/Sounds"); AssertFile("Game/Sounds.PAK", "Output/Packer/Sounds.PAK"); cPacker.Pack("Output/Packer/Textures.PAK", "Input/Game/PAK/Textures"); AssertFile("Game/Textures.PAK", "Output/Packer/Textures.PAK"); cPacker.Pack("Output/Packer/Videos.PAK", "Input/Game/PAK/Videos"); AssertFile("Game/Videos.PAK", "Output/Packer/Videos.PAK"); }
int SetArgument(int argc, int i, char *argv[], user_settings *set) { u16 ParamNum = 0; for (int j = i + 1; j < argc && argv[j][0] != '-'; j++) ParamNum++; // Global Settings if (strcmp(argv[i], "-rsf") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->common.rsfPath = argv[i + 1]; return 2; } else if (strcmp(argv[i], "-f") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } if (strcasecmp(argv[i + 1], "ncch") == 0 || strcasecmp(argv[i + 1], "cxi") == 0 || strcasecmp(argv[i + 1], "cfa") == 0) set->common.outFormat = NCCH; else if (strcasecmp(argv[i + 1], "cci") == 0) set->common.outFormat = CCI; else if (strcasecmp(argv[i + 1], "cia") == 0) set->common.outFormat = CIA; else { fprintf(stderr, "[SETTING ERROR] Invalid output format '%s'\n", argv[i + 1]); return USR_BAD_ARG; } return 2; } else if (strcmp(argv[i], "-o") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->common.outFileName = argv[i + 1]; set->common.outFileName_mallocd = false; return 2; } else if (strcmp(argv[i], "-v") == 0) { if (ParamNum) { PrintNoNeedParam(argv[i]); return USR_BAD_ARG; } set->common.verbose = true; return 1; } // Key Options else if (strcmp(argv[i], "-target") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } if (strcasecmp(argv[i + 1], "test") == 0 || strcasecmp(argv[i + 1], "t") == 0) { set->common.keys.keyset = pki_TEST; } //else if(strcasecmp(argv[i+1],"beta") == 0 || strcasecmp(argv[i+1],"b") == 0) { // set->common.keys.keyset = pki_BETA; //} else if (strcasecmp(argv[i + 1], "debug") == 0 || strcasecmp(argv[i + 1], "development") == 0 || strcasecmp(argv[i + 1], "d") == 0) { set->common.keys.keyset = pki_DEVELOPMENT; } else if (strcasecmp(argv[i + 1], "retail") == 0 || strcasecmp(argv[i + 1], "production") == 0 || strcasecmp(argv[i + 1], "p") == 0) { set->common.keys.keyset = pki_PRODUCTION; } //else if(strcasecmp(argv[i+1],"custom") == 0 || strcasecmp(argv[i+1],"c") == 0) { // set->common.keys.keyset = pki_CUSTOM; //} else { fprintf(stderr, "[SETTING ERROR] Unrecognised target '%s'\n", argv[i + 1]); return USR_BAD_ARG; } return 2; } else if (strcmp(argv[i], "-ckeyid") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->common.keys.aes.currentCommonKey = strtol(argv[i + 1], NULL, 0); if (set->common.keys.aes.currentCommonKey > MAX_CMN_KEY) { fprintf(stderr, "[SETTING ERROR] Invalid Common Key Index: 0x%x\n", set->common.keys.aes.currentCommonKey); return USR_BAD_ARG; } return 2; } else if (strcmp(argv[i], "-ncchseckey") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.useSecCrypto = true; set->ncch.keyXID = strtol(argv[i + 1], NULL, 0); if (set->ncch.keyXID > MAX_NCCH_KEYX) { fprintf(stderr, "[SETTING ERROR] Invalid NCCH KeyX Index: 0x%x\n", set->ncch.keyXID); return USR_BAD_ARG; } return 2; } else if (strcmp(argv[i], "-showkeys") == 0) { if (ParamNum) { PrintNoNeedParam(argv[i]); return USR_BAD_ARG; } set->common.keys.dumpkeys = true; return 1; } else if (strcmp(argv[i], "-fsign") == 0) { if (ParamNum) { PrintNoNeedParam(argv[i]); return USR_BAD_ARG; } set->common.keys.rsa.isFalseSign = true; return 1; } // Ncch Options else if (strcmp(argv[i], "-elf") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.elfPath = argv[i + 1]; set->ncch.ncchType |= CXI; return 2; } else if (strcmp(argv[i], "-icon") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.iconPath = argv[i + 1]; set->ncch.ncchType |= CFA; return 2; } else if (strcmp(argv[i], "-banner") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.bannerPath = argv[i + 1]; set->ncch.ncchType |= CFA; return 2; } else if (strcmp(argv[i], "-logo") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.logoPath = argv[i + 1]; set->ncch.ncchType |= CFA; return 2; } else if (strcmp(argv[i], "-desc") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } char *tmp = argv[i + 1]; char *tmp2 = strstr(tmp, ":"); if (!tmp2) { fprintf(stderr, "[SETTING ERROR] Bad argument '%s %s', correct format:\n", argv[i], argv[i + 1]); fprintf(stderr, " -desc <APP TYPE>:<TARGET FIRMWARE>\n"); } if (strlen(tmp2) < 2) { fprintf(stderr, "[SETTING ERROR] Bad argument '%s %s', correct format:\n", argv[i], argv[i + 1]); fprintf(stderr, " -desc <APP TYPE>:<TARGET FIRMWARE>\n"); } u32 app_type_len = (u32)(tmp2 - tmp); char *app_type = calloc(app_type_len + 1, sizeof(char)); memcpy(app_type, tmp, app_type_len); if (strcasecmp(app_type, "App") == 0 || strcasecmp(app_type, "SDApp") == 0) set->common.keys.accessDescSign.presetType = desc_Application; else if (strcasecmp(app_type, "ECApp") == 0) set->common.keys.accessDescSign.presetType = desc_EcApplication; else if (strcasecmp(app_type, "Demo") == 0) set->common.keys.accessDescSign.presetType = desc_Demo; else if (strcasecmp(app_type, "DlpChild") == 0 || strcasecmp(app_type, "Dlp") == 0) set->common.keys.accessDescSign.presetType = desc_DlpChild; else if (strcasecmp(app_type, "ExtApp") == 0) set->common.keys.accessDescSign.presetType = desc_ExtApplication; else if (strcasecmp(app_type, "ExtDemo") == 0) set->common.keys.accessDescSign.presetType = desc_ExtDemo; else if (strcasecmp(app_type, "ExtDlpChild") == 0 || strcasecmp(app_type, "ExtDlp") == 0) set->common.keys.accessDescSign.presetType = desc_ExtDlpChild; else { fprintf(stderr, "[SETTING ERROR] Accessdesc AppType preset '%s' not valid, please manually configure RSF\n", app_type); return USR_BAD_ARG; } char *target_firmware = (tmp2 + 1); set->common.keys.accessDescSign.targetFirmware = strtoul(target_firmware, NULL, 0); switch (set->common.keys.accessDescSign.targetFirmware) { case 1: set->common.keys.accessDescSign.targetFirmware = 0x1B; // or 0x1C break; case 2: set->common.keys.accessDescSign.targetFirmware = 0x1D; // or 0x1E/0x1F break; case 3: set->common.keys.accessDescSign.targetFirmware = 0x20; break; case 4: set->common.keys.accessDescSign.targetFirmware = 0x21; // or 0x22 break; case 5: set->common.keys.accessDescSign.targetFirmware = 0x23; // or 0x24 break; case 6: set->common.keys.accessDescSign.targetFirmware = 0x25; // or 0x26 break; case 7: set->common.keys.accessDescSign.targetFirmware = 0x27; // or 0x28 break; case 8: set->common.keys.accessDescSign.targetFirmware = 0x2C; break; default: break; } set->ncch.ncchType |= CXI; return 2; } else if (strcmp(argv[i], "-exefslogo") == 0) { if (ParamNum) { PrintNoNeedParam(argv[i]); return USR_BAD_ARG; } set->ncch.includeExefsLogo = true; set->ncch.ncchType |= CFA; return 1; } // Ncch Rebuild Options else if (strcmp(argv[i], "-code") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.codePath = argv[i + 1]; set->ncch.ncchType |= CXI; return 2; } else if (strcmp(argv[i], "-exheader") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.exheaderPath = argv[i + 1]; set->ncch.ncchType |= CXI; return 2; } else if (strcmp(argv[i], "-plainrgn") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.plainRegionPath = argv[i + 1]; set->ncch.ncchType |= CXI; return 2; } else if (strcmp(argv[i], "-romfs") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->ncch.romfsPath = argv[i + 1]; set->ncch.ncchType |= CFA; return 2; } // Cci Options else if (strcmp(argv[i], "-devcci") == 0) { if (ParamNum) { PrintNoNeedParam(argv[i]); return USR_BAD_ARG; } set->cci.useSDKStockData = true; return 1; } else if (strcmp(argv[i], "-nomodtid") == 0) { if (ParamNum) { PrintNoNeedParam(argv[i]); return USR_BAD_ARG; } set->cci.dontModifyNcchTitleID = true; return 1; } else if (strcmp(argv[i], "-alignwr") == 0) { if (ParamNum) { PrintNoNeedParam(argv[i]); return USR_BAD_ARG; } set->cci.closeAlignWritableRegion = true; return 1; } else if (strcmp(argv[i], "-cverinfo") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_BAD_ARG; } char *pos = strstr(argv[i + 1], ":"); if (!pos || strlen(pos) < 2) { fprintf(stderr, "[SETTING ERROR] Bad argument '%s %s', correct format:\n", argv[i], argv[i + 1]); fprintf(stderr, " %s <DATA PATH>:<'cia'/'tmd'>\n", argv[i]); return USR_BAD_ARG; } char *dtype = pos + 1; if (strcasecmp(dtype, "tmd") == 0) set->cci.cverDataType = CVER_DTYPE_TMD; else if (strcasecmp(dtype, "cia") == 0) set->cci.cverDataType = CVER_DTYPE_CIA; else { fprintf(stderr, "[SETTING ERROR] Unrecognised cver data type:\"%s\"\n", dtype); return USR_BAD_ARG; } u32 path_len = (pos - argv[i + 1]) + 1; set->cci.cverDataPath = calloc(path_len, sizeof(char)); strncpy(set->cci.cverDataPath, argv[i + 1], path_len - 1); if (!AssertFile(set->cci.cverDataPath)) { fprintf(stderr, "[SETTING ERROR] Failed to open '%s'\n", set->cci.cverDataPath); return USR_BAD_ARG; } return 2; } // Cia Options else if (strcmp(argv[i], "-ver") == 0) { if (ParamNum != 1) { PrintArgReqParam(argv[i], 1); return USR_ARG_REQ_PARAM; } set->cia.useFullTitleVer = true; u32 ver = strtoul(argv[i + 1], NULL, 0); if (ver > VER_MAX) { fprintf(stderr, "[SETTING ERROR] Version: '%d' is too large, max: '%d'\n", ver, VER_MAX); return USR_BAD_ARG; } set->cia.titleVersion[VER_MAJOR] = (ver >> 10) & VER_MAJOR_MAX; set->cia.titleVersion[VER_MINOR] = (ver >> 4) & VER_MINOR_MAX; set->cia.titleVersion[VER_MICRO] = ver & VER_MICRO_MAX; return 2; } else if (strcmp(argv[i], "-major") == 0) {
bool KStoreCreateInfoManager::Reload(const char* szFilePath) { ASSERT_RETURN(szFilePath, false); KTabfileLoader& loader = KTabfileLoader::GetInstance(); KTabFile2* tabFile = loader.GetFileReader(szFilePath); if( NULL == tabFile ) { AssertFile(szFilePath); return false; } int nRet = -1; int lnValue = 0; KStoreCreateInfo* pStoreCreateInfo = NULL; char szValue[200] = ""; while(true) { nRet = tabFile->ReadLine(); if(nRet == -1) { loader.CloseFileReader(tabFile); AssertFile(szFilePath); return false; } if(nRet == 0) break; tabFile->GetInteger("StoreID", 0, &lnValue); pStoreCreateInfo = GetStoreCreateInfo(lnValue); if(NULL == pStoreCreateInfo) { pStoreCreateInfo = KStoreCreateInfo::Alloc(); pStoreCreateInfo->Initialize(); pStoreCreateInfo->m_nStoreID = lnValue; mMapStoreCreateInfo.insert_unique(lnValue, pStoreCreateInfo); pStoreCreateInfo = GetStoreCreateInfo(lnValue); ASSERT_I(pStoreCreateInfo); } tabFile->GetInteger("ID", 0, &lnValue); KStoreProduct* pStoreProduct = pStoreCreateInfo->GetStoreProduct(lnValue); if(NULL == pStoreProduct) { pStoreProduct = KStoreProduct::Alloc(); pStoreProduct->Initialize(); pStoreProduct->m_nID = lnValue; pStoreProduct->m_nStoreID = pStoreCreateInfo->m_nStoreID; pStoreCreateInfo->Insert(lnValue, pStoreProduct); pStoreProduct = pStoreCreateInfo->GetStoreProduct(lnValue); ASSERT_I(pStoreProduct); } tabFile->GetInteger("LabelID", 0, &lnValue); pStoreProduct->m_nLabelID = lnValue; tabFile->GetInteger("ItemID", 0, &lnValue); pStoreProduct->m_dwItemID = lnValue; tabFile->GetInteger("PileCount", 0, &lnValue); pStoreProduct->m_nPileCount = lnValue; int nPriceType, TParam1, TParam2; tabFile->GetInteger( "PriceType1", 0, &nPriceType); tabFile->GetInteger("T1Param1", 0, &TParam1); tabFile->GetInteger("T1Param2", 0, &TParam2); pStoreProduct->AddProductPrice(nPriceType, TParam1, TParam2); tabFile->GetInteger( "PriceType2", 0, &nPriceType); tabFile->GetInteger("T2Param1", 0, &TParam1); tabFile->GetInteger("T2Param2", 0, &TParam2); pStoreProduct->AddProductPrice(nPriceType, TParam1, TParam2); tabFile->GetInteger("LimitSaleCount", 0, &lnValue); pStoreProduct->m_nLimitSaleCount = lnValue; tabFile->GetString("CanBuyScript", "", szValue, sizeof(szValue)); pStoreProduct->m_strCanBuyScript.clear(); if(strcmp(szValue, "0")) { pStoreProduct->m_strCanBuyScript.append(szValue); } tabFile->GetString("CanSeeScript", "", szValue, sizeof(szValue)); pStoreProduct->m_strCanSeeScript.clear(); if(strcmp(szValue, "0")) { pStoreProduct->m_strCanSeeScript.append(szValue); } } loader.CloseFileReader(tabFile); return true; }
void TestObjectWriterChunkedSerialised(void) { ObjectsInit(); CObjectWriterChunked cWriter; CObjectGraphSerialiser cGraphSerialiser; Ptr<CTestWithArray> pcObject1; Ptr<CTestInteger> pcObject2; Ptr<CTestInteger> pcObject3; Ptr<CTestInteger> pcObject4; CChunkFileNames cChunkFile; int iLength; char szTest[4]; pcObject1 = ONMalloc(CTestWithArray, "Base/Level 1/Warning"); pcObject1->Init("Talking Clock", 17); pcObject2 = OMalloc(CTestInteger); pcObject2->Init(2, 9, 937); pcObject1->Add(pcObject2); pcObject3 = OMalloc(CTestInteger); pcObject3->Init(3, 7321, 7); pcObject1->Add(pcObject3); pcObject4 = OMalloc(CTestInteger); pcObject4->Init(4, 5, 6); pcObject1->Add(pcObject4); cWriter.Init("Output\\ObjectWriterChunked\\Test\\", "Base/Level 1", "ChunkFile"); cGraphSerialiser.Init(&cWriter); AssertTrue(cGraphSerialiser.Write(&pcObject1)); cGraphSerialiser.Kill(); cWriter.Kill(); AssertFile("Input/ChunkFile.DRG", "Output/ObjectWriterChunked/Test/Base/Level 1/ChunkFile.DRG"); cChunkFile.Init(DiskFile("Output/ObjectWriterChunked/Test/Base/Level 1/ChunkFile.DRG")); AssertTrue(cChunkFile.ReadOpen()); //CTestWithArray pcObject1 AssertTrue(cChunkFile.ReadChunkBegin("Warning")); AssertTrue(cChunkFile.ReadInt(&iLength)); AssertInt(106, iLength); AssertTrue(cChunkFile.ReadData(szTest, 4)); AssertString("NAM", szTest); AssertTrue(cChunkFile.ReadChunkEnd()); //CArrayObject AssertTrue(cChunkFile.ReadChunkBegin("Unnamed/0000000000000002")); AssertTrue(cChunkFile.ReadInt(&iLength)); AssertInt(101, iLength); AssertTrue(cChunkFile.ReadData(szTest, 4)); AssertString("IDX", szTest); AssertTrue(cChunkFile.ReadChunkEnd()); //CTestInteger pcObject2 AssertTrue(cChunkFile.ReadChunkBegin("Unnamed/0000000000000003")); AssertTrue(cChunkFile.ReadInt(&iLength)); AssertInt(45, iLength); AssertTrue(cChunkFile.ReadData(szTest, 4)); AssertString("IDX", szTest); AssertTrue(cChunkFile.ReadChunkEnd()); //CTestInteger pcObject3 AssertTrue(cChunkFile.ReadChunkBegin("Unnamed/0000000000000004")); AssertTrue(cChunkFile.ReadInt(&iLength)); AssertInt(45, iLength); AssertTrue(cChunkFile.ReadData(szTest, 4)); AssertString("IDX", szTest); AssertTrue(cChunkFile.ReadChunkEnd()); //CTestInteger pcObject4 AssertTrue(cChunkFile.ReadChunkBegin("Unnamed/0000000000000005")); AssertTrue(cChunkFile.ReadInt(&iLength)); AssertInt(45, iLength); AssertTrue(cChunkFile.ReadData(szTest, 4)); AssertString("IDX", szTest); AssertTrue(cChunkFile.ReadChunkEnd()); AssertTrue(cChunkFile.ReadClose()); cChunkFile.Kill(); ObjectsKill(); }
void TestObjectsFlushDurable(void) { CFileUtil cFileUtil; BOOL bResult; CIndexedConfig cConfig; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/Flush2"); cConfig.OptimiseForStreaming("Output/Flush2"); cConfig.SetObjectCacheSize(128 MB); //cConfig.SetWriteThrough(FALSE); ObjectsInit(&cConfig); SetupObjectsForDehollowfication(); AssertLongLongInt(0, gcObjects.NumDatabaseObjects()); AssertLongLongInt(0, gcObjects.NumDatabaseNames()); AssertLongLongInt(9, gcObjects.NumMemoryIndexes()); AssertLongLongInt(6, gcObjects.NumMemoryNames()); bResult = gcObjects.Flush(FALSE, FALSE); AssertTrue(bResult); AssertLongLongInt(9, gcObjects.NumDatabaseObjects()); AssertLongLongInt(6, gcObjects.NumDatabaseNames()); AssertLongLongInt(9, gcObjects.NumMemoryIndexes()); AssertLongLongInt(6, gcObjects.NumMemoryNames()); ObjectsKill(); AssertFile("Input/Dehollowfication/48_0.DAT", "Output/Flush2/48_0.DAT"); AssertFile("Input/Dehollowfication/56_0.DAT", "Output/Flush2/56_0.DAT"); AssertFile("Input/Dehollowfication/68_0.DAT", "Output/Flush2/68_0.DAT"); AssertFile("Input/Dehollowfication/89_0.DAT", "Output/Flush2/89_0.DAT"); AssertFile("Input/Dehollowfication/93_0.DAT", "Output/Flush2/93_0.DAT"); AssertFile("Input/Dehollowfication/101_0.DAT", "Output/Flush2/101_0.DAT"); AssertFile("Input/Dehollowfication/102_0.DAT", "Output/Flush2/102_0.DAT"); AssertFile("Input/Dehollowfication/Files.DAT", "Output/Flush2/Files.DAT"); AssertFile("Input/Dehollowfication/Indicies.DAT", "Output/Flush2/Indicies.DAT"); AssertFile("Input/Dehollowfication/32_0.NAM", "Output/Flush2/32_0.NAM"); AssertFile("Input/Dehollowfication/Files.NAM", "Output/Flush2/Files.NAM"); }