本文整理汇总了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();
}
示例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);
//.........这里部分代码省略.........
示例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");
}