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();
}
Пример #2
0
int
ready_Output_Device(int frame)
{
    int size;
    if (force_cellsz) {
	grid_sz = (int)(view_size / cell_sz);
	V_MAX(grid_sz, 1); /* must be non-zero */
	setGridSize(grid_sz);
	prnt_Status();
    }
    /* Calculate size of frame buffer image (pixels across square image). */
    if (movie.m_noframes > 1 && ! movie.m_fullscreen)
	/* Fit frames of movie. */
	size = MovieSize(grid_sz, movie.m_noframes);
    else
	if (force_fbsz && ! DiskFile(fb_file))
	    size = fb_size; /* user-specified size */
	else
	    size = grid_sz; /* just 1 pixel/ray */
    if (movie.m_noframes > 1 && movie.m_fullscreen) {
	char framefile[MAX_LN];
	/* We must be doing full-screen frames. */
	size = grid_sz;
	(void) snprintf(framefile, MAX_LN, "%s.%04d", prefix, frame);
	if (! fb_Setup(framefile, size))
	    return 0;
    } else {
	if (frame == movie.m_curframe && ! fb_Setup(fb_file, size))
	    return 0;
	fb_Zoom_Window();
    }
    return 1;
}
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);
}
BOOL CNamedIndexesOptimiser::OpenDestinationFile(CFileBasic* pcDestFile, char* szName)
{
	CChars							szFullName;
	
	pcDestFile->Init(BufferedFile(DiskFile(TempFileName(&szFullName, szName)), 10 MB));
	szFullName.Kill();
	return pcDestFile->Open(EFM_Write_Create);
}
BOOL LoadTGA(CImage* pcImage, char* szFilename)
{
	static char uTGAcompare[12] = {0,0, 2,0,0,0,0,0,0,0,0,0}; // Uncompressed True Colour TGA Header
	//static char cTGAcompare[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; // Compressed True Colour TGA Header
	STGAFileHeader tgaheader;				

	CFileBasic sFile;


	//----------------------------------------------------------------------
	// open the tga file.
	//----------------------------------------------------------------------
	sFile.Init(DiskFile(szFilename));
	if (!sFile.Open(EFM_Read))
	{
		sFile.Kill();
		return FALSE;
	}

	//----------------------------------------------------------------------
	// read the header
	//----------------------------------------------------------------------
	if (sFile.Read(&tgaheader, 1, 12) != 12)
	{
		sFile.Close();
		sFile.Kill();
		return FALSE;
	}

	sFile.Close();
	sFile.Kill();

	//----------------------------------------------------------------------
	// check whether the TGA Header matches a compressed one or not
	//----------------------------------------------------------------------
	if (memcmp(uTGAcompare, &tgaheader, 12) == 0)
	{
		return LoadUncompressedTrueColourTGA(pcImage, szFilename);
	}
	/*
	else 
	if (memcmp(cTGAcompare, &tgaheader, 10) == 0)
	{											
	return LoadCompressedTrueColourTGA(pcImage, filename);
	}
	*/

	//----------------------------------------------------------------------
	// if no header is matched, this is not a supported TGA format.
	//----------------------------------------------------------------------
	return FALSE;
}
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();
}
Пример #7
0
void CLogger::Init(char* szName)
{
	CFileUtil cFileUtil;

	cFileUtil.Delete(szName);
	Init(DiskFile(szName), szName);
	mbFreeFile = TRUE;
	msConfig.bEngineOut = TRUE;

	msConfig.bBreakOnWarning = FALSE;
	msConfig.bBreakOnError = FALSE;

#ifdef BREAK_ON_ERROR
	msConfig.bBreakOnError = TRUE;
#endif

#ifdef BREAK_ON_WARNING
	msConfig.bBreakOnError = TRUE;
	msConfig.bBreakOnWarning = TRUE;
#endif
}
Пример #8
0
CDiskFile* CFiles::GetSystemFile(char* szFullName)
{
	CChars					szRemain;
	CFileNodeSystemFile*	pcNode;
	char*					szName;
	CDiskFile*				pcDiskFile;

	szRemain.Init();
	pcNode = mcFileSystem.GetFileNode(szFullName, &szRemain);
	if (pcNode)
	{
		if (szRemain.Length() == 0)
		{
			szName = pcNode->GetFullName();
			pcDiskFile = DiskFile(szName);
			szRemain.Kill();
			return pcDiskFile;
		}
		szRemain.Kill();
	}
	return NULL;
}
void TestBufferedFileReadWrite(void)
{
	CFileUtil	cFileUtil;
	CFileBasic	cFile;
	CTextFile	cText;
	char		sz[20];

	cFileUtil.Delete("Test.txt");

	cFile.Init(BufferedFile(DiskFile("Test.txt"), 3));
	cFile.Open(EFM_ReadWrite_Create);
	cFile.Write("abcdefghijklmn", 1, 14);
	cFile.Write("op", 1, 2);
	cFile.Seek(3);
	memset(sz, 0, 20);
	cFile.Read(sz, 2, 1);
	AssertString("de", sz);
	cFile.Read(sz, 2, 1);
	AssertString("fg", sz);
	cFile.Write("12", 2, 1);
	cFile.Read(sz, 2, 1);
	AssertString("jk", sz);
	cFile.Write("34", 2, 1);
	cFile.Read(sz, 2, 1);
	AssertString("no", sz);
	cFile.Seek(2);
	cFile.Write("XY", 2, 1);
	cFile.Read(sz, 1, 3);
	AssertString("efg", sz);
	cFile.Close();
	cFile.Kill();

	cText.Init();
	cText.Read("Test.txt");
	AssertString("abXYefg12jk34nop", cText.mcText.Text());
	cText.Kill();

	cFileUtil.Delete("Test.txt");
}
Пример #10
0
void CCSVHelper::Init(char* szFileName, char cSeparator)
{
	mcFile.Init(cSeparator);
	mcFile.Open(DiskFile(szFileName));
	mcFile.ReadAllLines();
}
Пример #11
0
void TestLogFileMultipleReadsAfterOpens(void)
{
	CLogFile*		pcLogFile;
	CDiskFile*		pcDiskFile;
	CFileBasic		cFile;
	CFileUtil		cFileUtil;
	char			szSource[] = {"The Name of the Wise Man"};
	int				iSourcelen;
	char			szResult[50];
	char			szWrite[] = {"Cat Catt ct... "};
	int				iWriteLen;
	char			szA[] = {"A"};

	cFileUtil.RemoveDir("Output/LogFile2");
	cFileUtil.MakeDir("Output/LogFile2");
	pcDiskFile = DiskFile("Output/LogFile2/OpenClose.txt");
	pcDiskFile->Open(EFM_ReadWrite_Create);
	iSourcelen = (int)strlen(szSource);
	pcDiskFile->Write(szSource, iSourcelen + 1, 1);
	pcDiskFile->Close();
	AssertTrue(cFileUtil.Exists("Output/LogFile2/OpenClose.txt"));

	pcLogFile = LogFile(pcDiskFile);
	cFile.Init(pcLogFile);
	pcLogFile->Begin();

	AssertTrue(cFile.Open(EFM_Read));
	AssertInt(iSourcelen + 1, (int)cFile.GetFileSize());
	cFile.ReadData(szResult, iSourcelen + 1);
	AssertString(szSource, szResult);
	cFile.Close();

	cFile.Open(EFM_ReadWrite_Create);
	iWriteLen = (int)strlen(szWrite);
	cFile.WriteData(szWrite, iWriteLen);
	AssertInt(iSourcelen + 1, (int)cFile.GetFileSize());
	pcLogFile->Close();

	cFile.Delete();
	AssertTrue(cFileUtil.Exists("Output/LogFile2/OpenClose.txt"));
	AssertInt(0, (int)cFile.GetFileSize());

	cFile.Open(EFM_ReadWrite_Create);
	cFile.Write(szA, 2, 1);
	AssertInt(2, (int)cFile.GetFileSize());

	cFile.Close();

	pcLogFile->Commit();
	cFile.Kill();

	AssertTrue(cFileUtil.Exists("Output/LogFile2/OpenClose.txt"));
	AssertInt(2, cFileUtil.Size("Output/LogFile2/OpenClose.txt"));

	pcDiskFile = DiskFile("Output/LogFile2/OpenClose.txt");
	pcLogFile = LogFile(pcDiskFile);
	cFile.Init(pcLogFile);
	pcLogFile->Begin();

	AssertTrue(cFile.Open(EFM_Read));
	cFile.ReadData(szResult, 2);
	AssertString("A", szResult);

	cFile.Seek(0);
	cFile.ReadData(szResult, 2);
	AssertString("A", szResult);

	cFile.Close();

	cFile.Delete();
	pcLogFile->Commit();
	cFile.Kill();

	AssertFalse(cFileUtil.Exists("Output/LogFile2/OpenClose.txt"));
}
Пример #12
0
BOOL LoadUncompressedTrueColourTGA(CImage *pcImage, char *szFilename)
{
	STGAImageHeader 		sTGAImageHeader;
	STGAFileHeader  		sTGAFileHeader;				// Used To Store Our File Header
	CFileBasic				sFile;
	int   					iWidth;
	int   					iHeight;
	int   					iBitsPerPixel;
	int   					iBytesPerPixel;
	int   					iImageSize;
	unsigned char*			pvMem;
	CImage					cImageImport;
	CImageCopier			cCopier;
	filePos					iRead;
	int						i;
	int						iStride;

	//----------------------------------------------------------------------
	// open the tga file.
	//----------------------------------------------------------------------
	sFile.Init(DiskFile(szFilename));
	if (!sFile.Open(EFM_Read))
	{
		sFile.Kill();
		return FALSE;
	}

	//----------------------------------------------------------------------
	// read the header
	//----------------------------------------------------------------------

	//Error check please.
	memset(&sTGAFileHeader, 0, sizeof(STGAFileHeader));
	sFile.Read(&sTGAFileHeader.iIDLength, 1, 1);
	sFile.Read(&sTGAFileHeader.iColourMapType, 1, 1);
	sFile.Read(&sTGAFileHeader.iImageType, 1, 1);
	sFile.Read(&sTGAFileHeader.iFirstEntryIndex, 2, 1);
	sFile.Read(&sTGAFileHeader.iColourMapLength, 2, 1);
	sFile.Read(&sTGAFileHeader.iColourMapEntrySize, 1, 1);
	sFile.Read(&sTGAFileHeader.iOriginX, 2, 1);
	sFile.Read(&sTGAFileHeader.iOriginY, 2, 1);

	//Error check please.
	memset(&sTGAImageHeader, 0, sizeof(STGAImageHeader));
	sFile.Read(&sTGAImageHeader.iImageWidth, 2, 1);
	sFile.Read(&sTGAImageHeader.iImageHeight, 2, 1);
	sFile.Read(&sTGAImageHeader.iPixelDepth, 1, 1);
	sFile.Read(&sTGAImageHeader.iPixelDescriptor, 1, 1);


	//----------------------------------------------------------------------
	// get the TGA dimensions
	//----------------------------------------------------------------------
	iWidth        = (sTGAImageHeader.iImageWidth);
	iHeight       = (sTGAImageHeader.iImageHeight);
	iBitsPerPixel = sTGAImageHeader.iPixelDepth;

	//----------------------------------------------------------------------
	// Make Sure All Information Is Valid
	//----------------------------------------------------------------------
	if ((iWidth <= 0) || (iHeight <= 0))
	{
		sFile.Close();
		sFile.Kill();
		return FALSE;
	}

	switch (iBitsPerPixel)
	{
	case 16:
		iBytesPerPixel = 2;
		break;
	case 24:
		iBytesPerPixel = 3;
		break;
	case 32:
		iBytesPerPixel = 4;
		break;
	default:
		sFile.Close();
		sFile.Kill();
		return FALSE;
	}

	iBytesPerPixel = (iBitsPerPixel / 8);				  // Calculate The BYTES Per Pixel
	iImageSize     = (iBytesPerPixel * iWidth * iHeight); // Calculate Memory Needed To Store Image
	iStride = iWidth * iBytesPerPixel;

	pvMem = (unsigned char*)malloc(iImageSize);
	iRead = sFile.Read(pvMem, iImageSize, 1);
	if (iRead != 1)
	{
		free(pvMem);
		sFile.Close();
		sFile.Kill();
		return FALSE;	
	}
	sFile.Close();
	sFile.Kill();


	cImageImport.Init();
	cImageImport.BeginChange();
	pcImage->Init();
	pcImage->BeginChange();
	if (iBytesPerPixel == 3)
	{
		cImageImport.AddChannel(IMAGE_DIFFUSE_BLUE, IMAGE_DIFFUSE_GREEN, IMAGE_DIFFUSE_RED, PT_uchar);
		pcImage->AddChannel(IMAGE_DIFFUSE_RED, IMAGE_DIFFUSE_GREEN, IMAGE_DIFFUSE_BLUE, PT_uchar);
	}
	else if (iBytesPerPixel == 4)
	{
		cImageImport.AddChannel(IMAGE_DIFFUSE_BLUE, IMAGE_DIFFUSE_GREEN, IMAGE_DIFFUSE_RED, IMAGE_OPACITY, PT_uchar);
		pcImage->AddChannel(IMAGE_OPACITY, IMAGE_DIFFUSE_RED, IMAGE_DIFFUSE_GREEN, IMAGE_DIFFUSE_BLUE, PT_uchar);
	}
	else if (iBytesPerPixel == 2)
	{
		cImageImport.AddChannel(IMAGE_DIFFUSE_BLUE, IMAGE_DIFFUSE_GREEN, IMAGE_DIFFUSE_RED, PT_nickle);
		cImageImport.AddChannel(IMAGE_IGNORED, PT_bit);
		pcImage->AddChannel(IMAGE_DIFFUSE_RED, IMAGE_DIFFUSE_GREEN, IMAGE_DIFFUSE_BLUE, PT_uchar);
	}
	cImageImport.SetSize(iWidth, iHeight);
	pcImage->SetSize(iWidth, iHeight);
	pcImage->EndChange();
	cImageImport.SetData(pvMem);
	cImageImport.EndChange();

	cCopier.Init(&cImageImport, pcImage);
	for (i = 0; i < iHeight; i++)
	{
		cImageImport.SetData(&pvMem[iStride* ((iHeight-1) - i)]);
		cCopier.Copy(0, i, 0, 0, iWidth, 1);
	}
	cCopier.Kill();
	cImageImport.Kill();

	free(pvMem);
	return TRUE;
}
void TestMapStringUnknownLoad(void)
{
    MemoryInit();
    UnknownsInit();

    CMapStringUnknown	cMap;
    CTestUnknownJobbie*	pcTest;
    CChunkFile			cFile;
    CFileUtil			cFileUtil;
    BOOL				bResult;

    gcUnknowns.AddConstructor<CTestUnknownJobbie>();
    AssertInt(0, gcUnknowns.NumElements());

    cFileUtil.RemoveDir("MapStringUnknown");
    cFileUtil.MakeDir("MapStringUnknown");

    cMap.Init();

    pcTest = cMap.Put<CTestUnknownJobbie>("Hello");
    pcTest->Init(7, "1st");
    pcTest = cMap.Put<CTestUnknownJobbie>("World");
    pcTest->Init(19, "A pony");
    pcTest = cMap.Put<CTestUnknownJobbie>("Aardvark");
    pcTest->Init(4, "Restore");
    pcTest = cMap.Put<CTestUnknownJobbie>("Yurk");
    pcTest->Init(8, "Yurk");

    cFile.Init(DiskFile("MapStringUnknown/Map.dat"));
    bResult = cFile.WriteOpen();
    AssertTrue(bResult);

    bResult = cMap.Save(&cFile);
    AssertTrue(bResult);

    bResult = cFile.WriteClose();
    AssertTrue(bResult);

    cFile.Kill();
    cMap.Kill();

    AssertInt(0, gcUnknowns.NumElements());

    cFile.Init(DiskFile("MapStringUnknown/Map.dat"));
    bResult = cFile.ReadOpen();
    AssertTrue(bResult);

    bResult = cMap.Load(&cFile);
    AssertTrue(bResult);

    bResult = cFile.ReadClose();
    AssertTrue(bResult);

    cFile.Kill();

    AssertInt(4, cMap.NumElements());
    AssertInt(4, gcUnknowns.NumElements());

    pcTest = (CTestUnknownJobbie*)cMap.Get("Hello");
    AssertInt(7, pcTest->miANumber);
    AssertString("1st", pcTest->mszText.Text());

    pcTest = (CTestUnknownJobbie*)cMap.Get("World");
    AssertInt(19, pcTest->miANumber);
    AssertString("A pony", pcTest->mszText.Text());

    pcTest = (CTestUnknownJobbie*)cMap.Get("Aardvark");
    AssertInt(4, pcTest->miANumber);
    AssertString("Restore", pcTest->mszText.Text());

    pcTest = (CTestUnknownJobbie*)cMap.Get("Yurk");
    AssertInt(8, pcTest->miANumber);
    AssertString("Yurk", pcTest->mszText.Text());

    cMap.Kill();

    AssertInt(0, gcUnknowns.NumElements());

    cFileUtil.RemoveDir("MapStringUnknown");

    UnknownsKill();
    MemoryKill();
}
void TestBufferedFileWrite(void)
{
	CFileUtil	cFileUtil;
	CFileBasic	cFile;
	CTextFile	cText;

	cFileUtil.Delete("Test.txt");

	cFile.Init(BufferedFile(DiskFile("Test.txt"), 3));
	cFile.Open(EFM_Write_Create);
	cFile.Write("ab", 1, 2);
	cFile.Write("cd", 1, 2);
	cFile.Close();
	cFile.Kill();

	cText.Init();
	cText.Read("Test.txt");
	AssertString("abcd", cText.mcText.Text());
	cText.Kill();

	cFile.Init(BufferedFile(DiskFile("Test.txt"), 5));
	cFile.Open(EFM_Write_Create);
	cFile.Write("abcdefghi", 1, 9);
	cFile.Write("jklmn", 1, 5);
	cFile.Close();
	cFile.Kill();

	cText.Init();
	cText.Read("Test.txt");
	AssertString("abcdefghijklmn", cText.mcText.Text());
	cText.Kill();

	cFile.Init(BufferedFile(DiskFile("Test.txt"), 5));
	cFile.Open(EFM_ReadWrite);
	cFile.Seek(4);
	cFile.Write("xyz", 3, 1);
	cFile.Close();
	cFile.Kill();

	cText.Init();
	cText.Read("Test.txt");
	AssertString("abcdxyzhijklmn", cText.mcText.Text());
	cText.Kill();

	cFile.Init(BufferedFile(DiskFile("Test.txt"), 8));
	cFile.Open(EFM_ReadWrite);
	cFile.Seek(0, EFSO_END);
	cFile.Write("opqrst", 6, 1);
	cFile.Seek(0);
	cFile.Write("123456", 6, 1);
	cFile.Write("78", 2, 1);
	cFile.Close();
	cFile.Kill();

	cText.Init();
	cText.Read("Test.txt");
	AssertString("12345678ijklmnopqrst", cText.mcText.Text());
	cText.Kill();

	cFile.Init(BufferedFile(DiskFile("Test.txt"), 3));
	cFile.Open(EFM_Write_Create);
	cFile.Write("ab", 1, 2);
	cFile.Write("cdef", 1, 4);
	cFile.Write("gh", 1, 2);
	cFile.Close();
	cFile.Kill();

	cText.Init();
	cText.Read("Test.txt");
	AssertString("abcdefgh", cText.mcText.Text());
	cText.Kill();

	cFileUtil.Delete("Test.txt");
}
void TestBufferedFileRead(void)
{
	CFileUtil	cFileUtil;
	CFileBasic	cFile;
	CTextFile	cText;
	char		sz[20];
	char		c;
	int			iCount;
	int			i;
	char		szExpected[20];

	cFileUtil.Delete("Test.txt");

	cText.Init();
	cText.mcText.Append("abcdefghijk");
	cText.Write("Test.txt");
	cText.Kill();

	cFile.Init(BufferedFile(DiskFile("Test.txt"), 3));

	cFile.Open(EFM_Read);

	for (c = 'a'; c <= 'k'; c++)
	{
		AssertFalse(cFile.IsEndOfFile());
		memset(sz, 0, 20);
		iCount = (int)cFile.Read(sz, 1, 1);
		AssertChar(c, sz[0]);
		AssertChar(0, sz[1]);
		AssertInt(1, iCount);
	}
	AssertTrue(cFile.IsEndOfFile());

	cFile.Seek(0);

	szExpected[2] = 0;
	for (i = 0; i < 5; i++)
	{
		AssertFalse(cFile.IsEndOfFile());
		memset(sz, 0, 20);
		iCount = (int)cFile.Read(sz, 1, 2);
		szExpected[0] = 'a' + (char)i * 2;
		szExpected[1] = 'b' + (char)i * 2;
		AssertString(szExpected, sz);
		AssertInt(2, iCount);
	}
	AssertFalse(cFile.IsEndOfFile());
	memset(sz, 0, 20);
	iCount = (int)cFile.Read(sz, 1, 2);
	AssertString("k", sz);
	AssertInt(1, iCount);
	AssertTrue(cFile.IsEndOfFile());

	cFile.Seek(0);

	szExpected[3] = 0;
	for (i = 0; i < 3; i++)
	{
		AssertFalse(cFile.IsEndOfFile());
		memset(sz, 0, 20);
		iCount = (int)cFile.Read(sz, 1, 3);
		szExpected[0] = 'a' + (char)i * 3;
		szExpected[1] = 'b' + (char)i * 3;
		szExpected[2] = 'c' + (char)i * 3;
		AssertString(szExpected, sz);
		AssertInt(3, iCount);
	}
	AssertFalse(cFile.IsEndOfFile());
	memset(sz, 0, 20);
	iCount = (int)cFile.Read(sz, 1, 3);
	AssertString("jk", sz);
	AssertInt(2, iCount);
	AssertTrue(cFile.IsEndOfFile());

	cFile.Kill();

	cFileUtil.Delete("Test.txt");
}
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();
}