当前位置: 首页>>代码示例>>C++>>正文


C++ CFileBasic::IsEndOfFile方法代码示例

本文整理汇总了C++中CFileBasic::IsEndOfFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileBasic::IsEndOfFile方法的具体用法?C++ CFileBasic::IsEndOfFile怎么用?C++ CFileBasic::IsEndOfFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFileBasic的用法示例。


在下文中一共展示了CFileBasic::IsEndOfFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TestLogFileRead

void TestLogFileRead(void)
{
	CLogFile*		pcLogFile;
	CMemoryFile*	pcMemoryFile;
	CFileBasic		cFile;
	BOOL			bResult;
	int				iLength;
	char			sz[200];
	filePos			iRead;

	pcMemoryFile = MemoryFile();
	cFile.Init(pcMemoryFile);
	cFile.Open(EFM_Write_Create);
	cFile.WriteString("The suspense is killing me!");
	cFile.Close();

	pcLogFile = LogFile(pcMemoryFile);
	cFile.Init(pcLogFile);

	bResult = cFile.Open(EFM_Read);
	AssertTrue(bResult);

	pcLogFile->Begin();

	bResult = cFile.ReadStringLength(&iLength);
	AssertTrue(bResult);
	AssertInt(28, iLength);
	AssertFalse(cFile.IsEndOfFile());
	bResult = cFile.ReadStringChars(sz, iLength);
	AssertString("The suspense is killing me!", sz);
	AssertTrue(cFile.IsEndOfFile());

	memset(sz, 0, 200);
	bResult = cFile.Seek(20);
	AssertTrue(bResult);
	bResult = cFile.ReadStringChars(sz, 8);
	AssertString("killing ", sz);
	AssertLongLongInt(28, cFile.GetFilePos());
	AssertFalse(cFile.IsEndOfFile());

	memset(sz, 0, 200);
	bResult = cFile.ReadStringChars(sz, 4);
	AssertString("me!", sz);
	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	iRead = cFile.Read(sz, 1, 1);
	AssertLongLongInt(0, iRead);
	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

	AssertLongLongInt(32, cFile.GetFilePos());
	AssertTrue(cFile.IsEndOfFile());

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

	cFile.Kill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:59,代码来源:TestLogFile.cpp

示例2: TestLogFileWrite

void TestLogFileWrite(void)
{
	CLogFile*		pcLogFile;
	CMemoryFile*	pcMemoryFile;
	CFileBasic		cFile;
	BOOL			bResult;
	int				iLength;
	char			sz[200];

	pcMemoryFile = MemoryFile();
	pcLogFile = LogFile(pcMemoryFile);
	cFile.Init(pcLogFile);

	bResult = cFile.Open(EFM_ReadWrite_Create);
	AssertTrue(bResult);

	bResult = cFile.WriteString("The suspense is killing me!");
	AssertTrue(bResult);
	AssertNull((char*)pcMemoryFile->GetBufferPointer());
	
	AssertInt(1, pcLogFile->GetNumWrites());
	AssertLongLongInt(32, pcLogFile->GetWriteSize(0));

	bResult = cFile.Seek(8);
	AssertTrue(bResult);

	bResult = cFile.WriteData("camisole", 8);
	AssertTrue(bResult);
	AssertInt(1, pcLogFile->GetNumWrites());
	AssertLongLongInt(32, pcLogFile->GetWriteSize(0));
	
	AssertNull((char*)pcMemoryFile->GetBufferPointer());
	cFile.Seek(0);
	bResult = cFile.ReadStringLength(&iLength);
	AssertTrue(bResult);
	AssertInt(28, iLength);
	AssertFalse(cFile.IsEndOfFile());
	bResult = cFile.ReadStringChars(sz, iLength);
	AssertString("The camisole is killing me!", sz);
	AssertTrue(cFile.IsEndOfFile());

	bResult = pcLogFile->Commit();
	AssertTrue(bResult);
	AssertString("The camisole is killing me!", (char*)RemapSinglePointer(pcMemoryFile->GetBufferPointer(), sizeof(int)));

	bResult = cFile.Close();  //This should go before Commit
	AssertTrue(bResult);

	pcLogFile->Begin();
	
	bResult = cFile.Open(EFM_ReadWrite_Create);
	AssertTrue(bResult);

	bResult = cFile.Seek(4);
	AssertTrue(bResult);
	bResult = cFile.WriteData("Dog", 3);

	bResult = cFile.Seek(20);
	AssertTrue(bResult);
	bResult = cFile.WriteData("plurgle", 7);

	AssertInt(2, pcLogFile->GetNumWrites());
	AssertLongLongInt(3, pcLogFile->GetWriteSize(0));
	AssertLongLongInt(7, pcLogFile->GetWriteSize(1));

	AssertString("The camisole is killing me!", (char*)RemapSinglePointer(pcMemoryFile->GetBufferPointer(), sizeof(int)));
	cFile.Seek(0);
	bResult = cFile.ReadStringLength(&iLength);
	AssertTrue(bResult);
	AssertInt(28, iLength);
	AssertFalse(cFile.IsEndOfFile());
	bResult = cFile.ReadStringChars(sz, iLength);
	AssertTrue(bResult);
	AssertString("Dog camisole is plurgle me!", sz);
	AssertTrue(cFile.IsEndOfFile());

	bResult = pcLogFile->Commit();
	AssertTrue(bResult);
	AssertString("Dog camisole is plurgle me!", (char*)RemapSinglePointer(pcMemoryFile->GetBufferPointer(), sizeof(int)));

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

	pcLogFile->Begin();

	bResult = cFile.Open(EFM_ReadWrite_Create);
	AssertTrue(bResult);

	cFile.Seek(4);
	cFile.WriteData("X", 1);
	cFile.Seek(6);
	bResult = cFile.WriteData("Z", 1);
	cFile.Seek(28);
	cFile.WriteData("A", 1);
	cFile.Seek(30);
	bResult = cFile.WriteData("C", 1);
	AssertInt(4, pcLogFile->GetNumWrites());

	cFile.Seek(5);
	cFile.WriteData("Y", 1);
//.........这里部分代码省略.........
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:101,代码来源:TestLogFile.cpp

示例3: TestBufferedFileRead

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");
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:78,代码来源:TestBufferedFile.cpp


注:本文中的CFileBasic::IsEndOfFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。