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 AssertPakFile(char* szFileName, char* szContents, CFiles* pcFiles) { CAbstractFile* pcFile; CTextFile cTextFile; pcFile = pcFiles->GetFile(szFileName); AssertNotNull(pcFile); cTextFile.Init(); cTextFile.Read(pcFile); AssertString(szContents, cTextFile.Text()); cTextFile.Kill(); }
void TestFilesSimple(void) { CFiles cFiles; CAbstractFile* pcFile; CTextFile cTextFile; //If this test fails you probably need to re-generate the source PAK files. //Use TestPackFilesPackerSimple to do this. cFiles.Init("Game", "PAK"); AssertInt(6, cFiles.GetNumPackFiles()); pcFile = cFiles.GetFile("Sounds/Santa/Seattle.txt"); AssertNotNull(pcFile); cTextFile.Init(); cTextFile.Read(pcFile); AssertString("All night long\r\n", cTextFile.Text()); cTextFile.Kill(); pcFile = cFiles.GetFile("Sounds/General.txt"); AssertNotNull(pcFile); cTextFile.Init(); cTextFile.Read(pcFile); AssertString("General", cTextFile.Text()); cTextFile.Kill(); pcFile = cFiles.GetFile("Sounds/Santa/Slay/Spelling.txt"); AssertNotNull(pcFile); cTextFile.Init(); cTextFile.Read(pcFile); AssertString("Spelling", cTextFile.Text()); cTextFile.Kill(); cFiles.Kill(); }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// void CCFile::Load(void) { CTextFile cFile; if (!mbLoaded) { mbLoaded = TRUE; cFile.Init(); cFile.Read(mszFullName.Text()); mszContents.Kill(); mszContents.Init(cFile.Text()); cFile.Kill(); } }