void CImageCelsSource::AddDiskFileSource(char* szFileName, char* szImageName, CImageCelSource* pcCelSource) { CImageSourceDiskFile* pcDiskFile; int iLen; CChars szNewName; CFileUtil cFileUtil; if (!szFileName) { return; } iLen = (int)strlen(szFileName); if (iLen == 0) { return; } pcDiskFile = UMalloc(CImageSourceDiskFile); if (szImageName) { pcDiskFile->Init(szFileName, szImageName); } else { szNewName.Init(szFileName); cFileUtil.RemovePath(&szNewName); pcDiskFile->Init(szFileName, szNewName.Text()); szNewName.Kill(); } AddSource(pcDiskFile, pcCelSource); }
void TestFileSystemNearest(void) { CFileSystem cSystem; CFileUtil cFileUtil; CChars szWorkingDirectory; CFileNodeSystemFile* pcNode; CChars szRemaining; szWorkingDirectory.Init("Finder"); cFileUtil.FullPath(&szWorkingDirectory); cSystem.Init("Finder"); szRemaining.Init(); pcNode = cSystem.GetFileNode("Lord/1.rar/Happy/Quan", &szRemaining); AssertNotNull(pcNode); AssertString("Happy/Quan", szRemaining.Text()); szRemaining.Kill(); szRemaining.Init(); pcNode = cSystem.GetFileNode("File.txt/Sad/Quan", &szRemaining); AssertNotNull(pcNode); AssertString("Sad/Quan", szRemaining.Text()); szRemaining.Kill(); cSystem.Kill(); }
BOOL CObjectWriterChunked::Begin(void) { CDiskFile* pcDiskFile; CFileUtil cFileUtil; CChars szFullDirectory; CChars szFileName; CObjectWriter::Begin(); szFullDirectory.Init(mszDirectory); cFileUtil.AppendToPath(&szFullDirectory, mszObjectBaseName.Text()); cFileUtil.MakeDir(szFullDirectory.Text()); szFileName.Init(szFullDirectory); szFullDirectory.Kill(); cFileUtil.AppendToPath(&szFileName, mszFileName.Text()); szFileName.Append("."); szFileName.Append(OBJECT_FILE_EXTENSION); pcDiskFile = DiskFile(szFileName.Text()); szFileName.Kill(); mcChunkFile.Init(pcDiskFile); return mcChunkFile.WriteOpen(CHUNKED_OBJECT_FILE); }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// void CCFile::Path(CChars* pszPath) { CFileUtil cFileUtil; pszPath->Init(mszFullName); cFileUtil.RemoveLastFromPath(pszPath); }
void TestChunkFileSimple(void) { CChunkFile cChunkFile; CFileUtil cFileUtil; int iChunkNum; cFileUtil.MakeDir("Output"); cFileUtil.Delete("Output/ChunkFile.bin"); cChunkFile.Init(DiskFile("Output/ChunkFile.bin")); AssertFalse(cChunkFile.IsOpen()); AssertTrue(cChunkFile.WriteOpen()); AssertTrue(cChunkFile.IsOpen()); AssertTrue(cChunkFile.WriteChunkBegin()); AssertTrue(cChunkFile.WriteChunkEnd("ThisChunk")); AssertTrue(cChunkFile.WriteClose()); AssertFalse(cChunkFile.IsOpen()); cChunkFile.Kill(); cChunkFile.Init(DiskFile("Output/ChunkFile.bin")); AssertFalse(cChunkFile.IsOpen()); AssertTrue(cChunkFile.ReadOpen()); AssertTrue(cChunkFile.IsOpen()); iChunkNum = cChunkFile.FindFirstChunkWithName("ThisChunk"); AssertInt(0, iChunkNum); AssertTrue(cChunkFile.ReadChunkBegin(iChunkNum)); AssertTrue(cChunkFile.ReadClose()); AssertFalse(cChunkFile.IsOpen()); cChunkFile.Kill(); }
void TestFileSystemInit(void) { CFileSystem cSystem; char* szFullName; CFileUtil cFileUtil; CChars szWorkingDirectory; CChars szTemp; CTextFile cTextFile; szWorkingDirectory.Init("Finder"); cFileUtil.FullPath(&szWorkingDirectory); cSystem.Init("Finder"); szFullName = cSystem.GetFileName("Lord/1.rar"); szTemp.Init(szFullName); szTemp.RemoveFromStart(szWorkingDirectory.Length()+1); szTemp.Replace(FILE_SEPARATOR[0], '/'); AssertString("Lord/1.rar", szTemp.Text()); szTemp.Kill(); szFullName = cSystem.GetFileName("File.txt"); cTextFile.Init(); cTextFile.Read(szFullName); AssertString("Hello World.", cTextFile.Text()); cTextFile.Kill(); cSystem.Kill(); }
void TestObjectsFlushRemovesStackPointers(void) { CFileUtil cFileUtil; Ptr<CTestDoubleNamedString> pDouble; Ptr<CRoot> pRoot; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/ClearPointers"); ObjectsInit("Output/ClearPointers"); SetupObjectsConstructors(); pRoot = ORoot(); gcObjects.Flush(TRUE, TRUE); AssertLongLongInt(2, gcObjects.NumDatabaseObjects()); AssertNull(&pRoot); pDouble = ONMalloc(CTestDoubleNamedString, "Double")->Init(); AssertString("CTestDoubleNamedString", pDouble.ClassName()); pRoot = ORoot(); AssertString("CRoot", pRoot.ClassName()); ObjectsKill(); }
void TestObjectsFlushClearGetByName(void) { CFileUtil cFileUtil; CPointer pObject; Ptr<CTestDoubleNamedString> pDouble; Ptr<CRoot> pRoot; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/Dehollowfication"); ObjectsInit("Output/Dehollowfication"); SetupObjectsConstructors(); pRoot = ORoot(); pDouble = ONMalloc(CTestDoubleNamedString, "Double")->Init(); pRoot->Add(pDouble); AssertLongLongInt(0, gcObjects.NumDatabaseObjects()); AssertLongLongInt(0, gcObjects.NumDatabaseNames()); pObject = gcObjects.Get(3); AssertNotNull(pObject.Object()); AssertString("CTestDoubleNamedString", pObject.ClassName()); gcObjects.Flush(TRUE, TRUE); AssertLongLongInt(3, gcObjects.NumDatabaseObjects()); AssertLongLongInt(2, gcObjects.NumDatabaseNames()); pObject = gcObjects.Get("Double"); AssertNotNull(pObject.Object()); AssertString("CTestDoubleNamedString", pObject.ClassName()); ObjectsKill(); }
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"); }
void TestDehollowficationFromDatabaseOfTwoPointers(void) { CIndexedConfig cConfig; CFileUtil cFileUtil; cConfig.Manual("Output\\Dehollowfication\\Database", FALSE, TRUE, FALSE, 1 MB); cFileUtil.RemoveDir("Output\\Dehollowfication\\Database"); MemoryInit(); ObjectsInit(&cConfig); SetupDehollowficationScene(); gcObjects.Flush(FALSE, FALSE); ObjectsKill(); MemoryKill(); MemoryInit(); ObjectsInit(&cConfig); SetupDehollowficationConstructors(); Ptr<CRoot> pRoot = ORoot(); Ptr<CTestDoubleNamedString> pDouble = pRoot->Get<CTestDoubleNamedString>("Double Start"); Ptr<CTestNamedString> pString1 = pDouble->mpSplit1; Ptr<CTestNamedString> pString2 = pDouble->mpSplit2; pString1->ClassName(); pString2->ClassName(); Ptr<CTestNamedString> pDiamond1 = pString1->mpAnother; Ptr<CTestNamedString> pDiamond2 = pString2->mpAnother; AssertTrue(pDiamond1.IsHollow()); AssertTrue(pDiamond2.IsHollow()); AssertPointer(pDiamond1.Object(), pDiamond2.Object()); AssertPointer(pString1->mpAnother.Object(), pString2->mpAnother.Object()); AssertLongLongInt(3LL, pDiamond1.GetIndex()); AssertLongLongInt(3LL, pDiamond2.GetIndex()); //Dehollofication of pDiamond1 happens here. pString1->mpAnother and pString2->mpAnother are remapped to the dehollowed diamond object. pDiamond1->ClassName(); AssertFalse(pDiamond1.IsHollow()); AssertFalse(pDiamond2.IsHollow()); //This should be false but it's not until I remap local pointers. AssertPointer(pDiamond1.Object(), pDiamond2.Object()); //These should be the same but they're not until I remap local pointers. AssertLongLongInt(3LL, pDiamond1.GetIndex()); AssertFalse(pString1->mpAnother.IsHollow()); AssertFalse(pString2->mpAnother.IsHollow()); AssertPointer(pString1->mpAnother.Object(), pString2->mpAnother.Object()); ObjectsKill(); MemoryKill(); }
void TestDurableSetAdd(void) { CFileUtil cFileUtil; CDurableFileController cController; CDurableFile cDurableFile1; CDurableFile cDurableFile2; CDurableFile cDurableFile3; CDurableFile cDurableFile4; char szDirectory[] = "Durable2"; char szRewrite[] = "_Durable2"; CDurableFile* pcDurableFile; cFileUtil.RemoveDir(szDirectory); cFileUtil.MakeDir(szDirectory); cFileUtil.RemoveDir(szRewrite); cFileUtil.MakeDir(szRewrite); cController.Init(szDirectory, szRewrite); cDurableFile1.Init(&cController, "Durable" _FS_ "1.txt", "Durable" _FS_ "_1.txt"); cDurableFile2.Init(&cController, "Durable" _FS_ "2.txt", "Durable" _FS_ "_2.txt"); cDurableFile3.Init(&cController, "Durable" _FS_ "3.txt", "Durable" _FS_ "_3.txt"); cDurableFile4.Init(&cController, "Durable" _FS_ "4.txt", "Durable" _FS_ "_4.txt"); cController.Begin(); cController.AddFile(&cDurableFile1); AssertInt(1, cController.NumFiles()); pcDurableFile = cController.GetFile(0); AssertPointer(&cDurableFile1, pcDurableFile); cController.AddFile(&cDurableFile1); AssertInt(1, cController.NumFiles()); pcDurableFile = cController.GetFile(0); AssertPointer(&cDurableFile1, pcDurableFile); cController.AddFile(&cDurableFile2); AssertInt(2, cController.NumFiles()); cController.AddFile(&cDurableFile3); AssertInt(3, cController.NumFiles()); cController.AddFile(&cDurableFile4); AssertInt(4, cController.NumFiles()); cController.AddFile(&cDurableFile2); AssertInt(4, cController.NumFiles()); cController.AddFile(&cDurableFile3); AssertInt(4, cController.NumFiles()); cController.AddFile(&cDurableFile4); AssertInt(4, cController.NumFiles()); cController.End(); cDurableFile1.Kill(); cDurableFile2.Kill(); cDurableFile3.Kill(); cDurableFile4.Kill(); cController.Kill(); }
void CTileMapXML::Init(char* szMapName, char* szTexturePath) { CFileUtil cFileUtil; mszMapName.Init(szMapName); mszTexturePath.Init(szTexturePath); cFileUtil.FullPath(&mszMapName); cFileUtil.FullPath(&mszTexturePath); }
BOOL CNamedIndexesOptimiser::CopyFile(char* szDestName, char* szSourceName) { CFileUtil cFileUtil; CChars szFullName; BOOL bResult; bResult = cFileUtil.Copy(TempFileName(&szFullName, szSourceName), szDestName); szFullName.Kill(); return bResult; }
void TestObjectDehollowfication(void) { CFileUtil cFileUtil; CPointer pPointer; CTestDoubleNamedString* pcInternal; Ptr<CTestDoubleNamedString> pDouble; Ptr<CTestNamedString> pSingle; int iClassSize; OIndex oiOld; OIndex oiNew; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/Dehollowfication"); ObjectsInit("Output/Dehollowfication"); SetupObjectsForDehollowfication(); gcObjects.Flush(TRUE, TRUE); AssertLongLongInt(9, gcObjects.NumDatabaseObjects()); ObjectsKill(); ObjectsInit("Output/Dehollowfication"); SetupObjectsConstructors(); AssertLongLongInt(9, gcObjects.NumDatabaseObjects()); AssertTrue(gcObjects.Contains("Double")); pPointer = gcObjects.Get("Double"); AssertNotNull(pPointer.Object()); AssertString("CTestDoubleNamedString", pPointer.ClassName()); pcInternal = (CTestDoubleNamedString*)pPointer.Object(); AssertTrue(pcInternal->mpSplit1.IsNotNull()); AssertTrue(pcInternal->mpSplit1.IsHollow()); AssertTrue(pcInternal->mpSplit2.IsNotNull()); AssertTrue(pcInternal->mpSplit2.IsHollow()); pDouble = pPointer; oiOld = pDouble->mpSplit1.GetIndex(); AssertTrue(pcInternal->mpSplit1.IsHollow()); //Making sure we haven't de-hollowed the object by calling GetIndex. //Problem - An oi of 1 is briefly assigned to the de-hollowed object and then it is reassigned back to its original value. iClassSize = pDouble->mpSplit1->ClassSize(); //The method call - ClassSize() - is irrelevant as long as the -> operator on mpSplit1 is invoked. AssertTrue(pcInternal->mpSplit1.IsNotNull()); AssertFalse(pcInternal->mpSplit1.IsHollow()); AssertInt(sizeof(CTestNamedString), iClassSize); AssertString("CTestNamedString", pcInternal->mpSplit1.ClassName()); oiNew = pDouble->mpSplit1.GetIndex(); AssertLongLongInt(oiOld, oiNew); pSingle = pDouble->mpSplit2; AssertTrue(pcInternal->mpSplit2.IsNotNull()); AssertTrue(pcInternal->mpSplit2.IsHollow()); ObjectsKill(); }
void TestFileUtilNaming(void) { CFileUtil cFileUtil; CChars sz; CChars szExpected; sz.Init(); cFileUtil.FullPath(&sz); sz.LowerCase(); szExpected.Init("C:\\GameEngine\\Test\\TestBaseLib\\TestBaseLib"); szExpected.LowerCase(); AssertString(szExpected.Text(), sz.Text()); szExpected.Kill(); sz.Kill(); sz.Init("c:\\Documents and Settings\\Joe\\..\\..\\"); cFileUtil.CollapsePath(&sz); AssertStringCase("C:\\", sz.Text(), FALSE); sz.Kill(); sz.Init("\\Documents\\and\\Settings\\..\\..\\Joe"); cFileUtil.CollapsePath(&sz); AssertString("\\Documents\\Joe", sz.Text()); sz.Kill(); sz.Init("\\Documents\\and\\Settings\\..\\..\\Joe\\"); cFileUtil.CollapsePath(&sz); AssertString("\\Documents\\Joe", sz.Text()); sz.Kill(); sz.Init(".\\.\\.\\."); cFileUtil.CollapsePath(&sz); AssertString("", sz.Text()); sz.Kill(); sz.Init(".\\.\\.\\"); cFileUtil.CollapsePath(&sz); AssertString("", sz.Text()); sz.Kill(); sz.Init("c:\\.."); cFileUtil.CollapsePath(&sz); AssertString("c:", sz.Text()); sz.Kill(); sz.Init("c:\\..\\.."); cFileUtil.CollapsePath(&sz); AssertString("c:", sz.Text()); sz.Kill(); sz.Init("\\..\\.."); cFileUtil.CollapsePath(&sz); AssertString("", sz.Text()); sz.Kill(); }
void TestIndexTreeWriterWrite(void) { char* pvData; char* pvKey; int iDataSize; BOOL bExists; int iKeyLength; CIndexTreeMemory cIndexTree; CMapStringString cMap; SMapIterator sMapIter; CIndexTreeWriter cWriter; CFileUtil cFileUtil; char szDirectory[] = "Output" _FS_ "IndexTreeMemoryWriter"; cMap.Init(3); cMap.Put("AA", "nutritious"); cMap.Put("AAA", "follow"); cMap.Put("AB", "lighten"); cMap.Put("BAAB", "ear"); cMap.Put("BB", "spotted"); cMap.Put("AAAAAAAAA", "hanging"); cMap.Put("ABBA", "mate"); cMap.Put("ABA", "blot"); cMap.Put("BCD", "smash"); cMap.Put("BBC", "cycle"); cMap.Put("BBB", "waggish"); cMap.Put("BBA", "debt"); AssertInt(12, cMap.NumElements()); cIndexTree.Init(); bExists = cMap.StartIteration(&sMapIter, (void**)&pvKey, (void**)&pvData); while (bExists) { iKeyLength = strlen((char*)pvKey); iDataSize = strlen((char*)pvData); cIndexTree.Put(pvKey, iKeyLength, pvData, (unsigned char)iDataSize); bExists = cMap.Iterate(&sMapIter, (void**)&pvKey, (void**)&pvData); } AssertInt(12, cIndexTree.NumElements()); cFileUtil.RemoveDir(szDirectory); cWriter.Write(&cIndexTree, szDirectory); cIndexTree.Kill(); cMap.Kill(); AssertTrue(cFileUtil.RemoveDir(szDirectory)); }
int main(int argc, _TCHAR* argv[]) { CFileUtil cFileUtil; InitTotalStatistics(); FastFunctionsInit(); TypesInit(); TypeConverterInit(); UnknownsInit(); cFileUtil.MakeDir("Output"); TestImage(); TestImageColour(); TestImageImport(); TestImageReader(); TestImageWriter(); TestImageGreyToRGB(); TestImageRGBToGrey(); TestImageDivider(); TestBumpMapper(); TestPlainTextEditor(); TestImageCel(); TestRectangleBestPacker(); TestRectanglePow2Packer(); TestImageModifierStack(); TestImageDrawBox(); TestImageRecolour(); TestImageSwizzle(); TestImageCombiner(); //TestWinText(); //TestImageCelsSource(); //TestHalfSpace(); //TestPolygon(); //TestSphereShape(); //TestTriangleShape(); //TestMeshFaceReturn(); //TestMeshPolygons(); //TestMeshShapes(); //TestMeshConnectivity(); //TestNormalGeneration(); //TestMeshOBJReader(); cFileUtil.RemoveDir("Output"); UnknownsKill(); TypeConverterKill(); TypesKill(); FastFunctionsKill(); return TestTotalStatistics(); }
void TestRemoveExtension(void) { CChars szFileName; CFileUtil cFileUtil; szFileName.Init("/mnt/world/hello.txt"); cFileUtil.RemoveExtension(&szFileName); AssertString("/mnt/world/hello", szFileName.Text()); cFileUtil.RemoveExtension(&szFileName); AssertString("/mnt/world/hello", szFileName.Text()); szFileName.Kill(); }
void CImageCelsSource::AddDiskFileSources(char* szPathName, char* szFileNameContains, char* szImageName, CImageCelSource* pcCelSource) { CFileUtil cFileUtil; CArrayString cFileNames; int i; CChars* pszName; CImageSourceDiskFile* pcDiskFile; CChars szNiceName; int iIndex; int iLen; if (!szFileNameContains) { return; } iLen = (int)strlen(szFileNameContains); if (iLen == 0) { return; } cFileNames.Init(32); cFileUtil.FindFilesWithNameContaining(szPathName, szFileNameContains, &cFileNames, FALSE); for (i = 0; i < cFileNames.NumElements(); i++) { pszName = cFileNames.Get(i); pcDiskFile = UMalloc(CImageSourceDiskFile); if (szImageName) { szNiceName.Init(*pszName); cFileUtil.RemovePath(&szNiceName); cFileUtil.RemoveExtension(&szNiceName); iIndex = szNiceName.Find(0, szFileNameContains); iIndex += iLen; szNiceName.RemoveFromStart(iIndex); szNiceName.Insert(0, szImageName); pcDiskFile->Init(pszName->Text(), szNiceName.Text()); szNiceName.Kill(); } else { pcDiskFile->Init(pszName->Text()); } AddSource(pcDiskFile, pcCelSource); } cFileNames.Kill(); }
BOOL CPackFiles::RecurseUnpack(CFileNodePackFileNode* pcNode, char* szDestination) { CChars szFileName; CFileNodePackFileNode* pcChild; int i; CPackFileNode* pcFile; BOOL bResult; CPackFile* pcPackFile; CFileCopier cCopier; CDiskFile cDiskFile; CFileUtil cFileUtil; if (pcNode->IsDirectory()) { bResult = TRUE; for (i = 0; i < pcNode->Directory()->maNodeFiles.NumElements(); i++) { pcChild = (CFileNodePackFileNode*)pcNode->Directory()->maNodeFiles.Get(i); bResult &= RecurseUnpack(pcChild, szDestination); } return bResult; } else if (pcNode->IsFile()) { szFileName.Init(szDestination); szFileName.Append('/'); pcNode->GetFullName(&szFileName); szFileName.Replace('/', FILE_SEPARATOR[0]); pcFile = pcNode->File(); pcPackFile = PackFile(this, pcFile); if (!pcPackFile) { szFileName.Kill(); return FALSE; } cDiskFile.Init(szFileName.Text()); cFileUtil.RemoveLastFromPath(&szFileName); cFileUtil.MakeDir(szFileName.Text()); bResult = cCopier.Copy(pcPackFile, &cDiskFile); cDiskFile.Kill(); szFileName.Kill(); return bResult; } return FALSE; }
BOOL CImageCelsSourceXML::ImportCels(CMarkupTag* pcCelsTag, char* szFileName) { STagIterator sIter; CSubImageXML cSubImageXML; CMarkupTag* pcCelTag; CArraySubImage acSubImages; CSubImage* pcSubImage; BOOL bResult; CImageCelSourceSubImages cSubImagesSource; CImageCelsSource cCelsSource; CChars szGroupName; CFileUtil cFileUtil; Ptr<CImageCelGroup> pcGroup; acSubImages.Init(); pcCelTag = pcCelsTag->GetTag("Cel", &sIter); while (pcCelTag) { pcSubImage = acSubImages.Add(); bResult = cSubImageXML.Import(pcCelTag, pcSubImage); if (!bResult) { acSubImages.Kill(); return FALSE; } pcCelTag = pcCelsTag->GetNextTag(&sIter); } cSubImagesSource.Init(&acSubImages); szGroupName.Init(szFileName); cFileUtil.RemovePath(&szGroupName); cCelsSource.Init(); cCelsSource.AddDiskFileSource(szFileName, szGroupName.Text(), &cSubImagesSource); cCelsSource.Load(); mpcWorld->AddImages(cCelsSource.GetImages()); pcGroup = ONMalloc(CImageCelGroup, szGroupName.Text()); mpcWorld->AddGroup(pcGroup); pcGroup->AddCels(cCelsSource.GetImageCels()); szGroupName.Kill(); cSubImagesSource.Kill(); cCelsSource.Kill(); acSubImages.Kill(); return TRUE; }
void TestObjectReaderSimple(void) { CFileUtil cFileUtil; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/ObjectReaderSimple"); BeginTests(); TestObjectReaderSimpleDeserialised(); TestStatistics(); cFileUtil.RemoveDir("Output"); }
void TestObjectWriterChunked(void) { CFileUtil cFileUtil; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/ObjectWriterChunked"); BeginTests(); TestObjectWriterChunkedWrite(); TestObjectWriterChunkedSerialised(); TestStatistics(); cFileUtil.RemoveDir("Output"); }
void CLibrary::Init(char* szName, char* szBaseDir, CHeaderFileMap* pcHeaderFileMap) { CFileUtil cFileUtil; CChars szPath; szPath.Init(szBaseDir); cFileUtil.FullPath(&szPath); mszName.Init(szName); mszBaseDir.Init(szPath); szPath.Kill(); mcConfigs.Init(); mcTranslationUnits.Init(this); mcHeaderNameMap.Init(mszBaseDir.Text(), pcHeaderFileMap, FALSE); }
BOOL CDurableFile::CopyBackupToPrimary(void) { CFileUtil cFileUtil; if (IsBegun()) { return FALSE; } if (!cFileUtil.Copy(mszRewriteName.Text(), mszFileName.Text())) { return FALSE; } return cFileUtil.Compare(mszFileName.Text(), mszRewriteName.Text()); }
void TestEmbeddedObjectPointTo(void) { BOOL bResult; CFileUtil cFileUtil; OIndex oiComplex; char* szClassName; cFileUtil.RemoveDir("Output/EmbeddedObject"); MemoryInit(); ObjectsInit("Output/EmbeddedObject/"); SetupEmbeddedObjectConstructors(); Ptr<CRoot> pRoot = ORoot(); Ptr<CEmbeddedComplex> pComplex = OMalloc(CEmbeddedComplex)->Init(); oiComplex = pComplex->GetOI(); Ptr<CEmbeddedContainer> pContainer = &pComplex->mcContainer; pRoot->Add(pContainer); bResult = gcObjects.Flush(TRUE, TRUE); AssertTrue(bResult); ObjectsKill(); MemoryKill(); AssertNull(&pContainer); MemoryInit(); ObjectsInit("Output/EmbeddedObject/"); SetupEmbeddedObjectConstructors(); pRoot = gcObjects.GetRoot(); AssertTrue(pRoot.IsNotNull()); pContainer = pRoot->Get(0); AssertTrue(pContainer.IsHollow()); AssertInt(0, pContainer.Object()->GetNumEmbedded()); AssertLongLongInt(-1, pContainer.GetIndex()); szClassName = pContainer->ClassName(); AssertString("CEmbeddedContainer", szClassName); pComplex = pContainer->GetEmbeddingContainer(); //Kinda feels like this test just stopped... ObjectsKill(); MemoryKill(); }
void TestDehollowficationFromChunkFileSource(void) { CFileUtil cFileUtil; cFileUtil.RemoveDir("Output\\Dehollowfication\\ChunkFile"); MemoryInit(); ObjectsInit("Output\\Dehollowfication\\Temp"); WriteDehollowficationChunkedFile(); ObjectsKill(); MemoryKill(); cFileUtil.RemoveDir("Output\\Dehollowfication\\Temp"); CObjectSourceChunked* pcObjectSourceChunked; CDiskFile* pcDiskFile = DiskFile("Output\\Dehollowfication\\ChunkFile\\Double.DRG"); MemoryInit(); ObjectsInit("Output\\Dehollowfication\\Temp"); SetupDehollowficationConstructors(); pcObjectSourceChunked = (CObjectSourceChunked*)gcObjects.AddSource<CObjectConverterNative>(pcDiskFile, "Double"); //Note the .DRG is intentionally dropped. AssertNotNull(pcObjectSourceChunked); AssertInt(4, pcObjectSourceChunked->NumNames()); AssertString("Diamond End", pcObjectSourceChunked->GetName(0)); AssertString("Double Start", pcObjectSourceChunked->GetName(1)); AssertString("NamedString 1", pcObjectSourceChunked->GetName(2)); AssertString("NamedString 2", pcObjectSourceChunked->GetName(3)); Ptr<CTestDoubleNamedString> pStart; pStart = gcObjects.Get("Double Start"); AssertTrue(pStart.IsNotNull()); AssertString("CTestDoubleNamedString", pStart.ClassName()); AssertTrue(pStart->mpSplit1.IsHollow()); AssertTrue(pStart->mpSplit2.IsHollow()); AssertFalse(pStart->mszString.IsHollow()); pStart->mpSplit1->ClassName(); AssertFalse(pStart->mpSplit1.IsHollow()); AssertString("CTestNamedString", pStart->mpSplit1.ClassName()); ObjectsKill(); MemoryKill(); }
void TestObjectReaderChunked(void) { CFileUtil cFileUtil; cFileUtil.RemoveDir("Output"); cFileUtil.MakeDir("Output/ObjectReaderChunked"); ObjectsInit(); BeginTests(); TestObjectReaderChunkedDeserialised(); TestStatistics(); ObjectsKill(); cFileUtil.RemoveDir("Output"); }
void TestObjectGraphDeserialiser(void) { CFileUtil cFileUtil; cFileUtil.RemoveDir("Output"); BeginTests(); TestRemappingOfSimpleFilesOIs(); TestRemappingOfChunkedFilesOIs(); TestOverwritingOfExistingNamesFromChunkedFiles(); TestStatistics(); cFileUtil.RemoveDir("Output"); }
BOOL CPackFiles::AddDirectory(char* szDirectory, char* szPackDirectory) { CFileUtil cFileUtil; CArrayChars aszFileNames; int i; CChars* pszFileName; CDiskFile cDiskFile; CChars szName; CChars szNameDirectory; BOOL bResult; BOOL bAnyFiles; aszFileNames.Init(); bAnyFiles = cFileUtil.FindAllFiles(szDirectory, &aszFileNames, TRUE, FALSE); if (!bAnyFiles) { aszFileNames.Kill(); return FALSE; } szNameDirectory.Init(szDirectory); for (i = 0; i < aszFileNames.NumElements(); i++) { pszFileName = aszFileNames.Get(i); cDiskFile.Init(pszFileName->Text()); cFileUtil.MakeNameFromDirectory(&szName, pszFileName, &szNameDirectory); if (szPackDirectory) { szName.Insert(0, '/'); szName.Insert(0, szPackDirectory); } bResult = AddFile(&cDiskFile, szName.Text()); szName.Kill(); cDiskFile.Kill(); if (!bResult) { aszFileNames.Kill(); return FALSE; } } aszFileNames.Kill(); return TRUE; }