void CTileMapXML::Init(char* szMapName, char* szTexturePath) { CFileUtil cFileUtil; mszMapName.Init(szMapName); mszTexturePath.Init(szTexturePath); cFileUtil.FullPath(&mszMapName); cFileUtil.FullPath(&mszTexturePath); }
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(); }
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 TestFileUtilTouchDirectory(void) { CFileUtil cFileUtil; CChars szDirectory; CChars szFileName; cFileUtil.RemoveDir("file_util"); szDirectory.Init("file_util" _FS_ "directory" _FS_ "make" _FS_ "test"); cFileUtil.FullPath(&szDirectory); szFileName.Init(szDirectory); cFileUtil.AppendToPath(&szFileName, "Warthog.PIG"); AssertTrue(cFileUtil.TouchDir(szFileName.Text())); AssertTrue(cFileUtil.Touch(szFileName.Text())); szDirectory.Kill(); szFileName.Kill(); cFileUtil.RemoveDir("file_util"); AssertFalse(cFileUtil.TouchDir("C:\\Warthog.PIG")); AssertFalse(cFileUtil.TouchDir("\\Warthog.PIG")); szDirectory.Init(); cFileUtil.CurrentDirectory(&szDirectory); szDirectory.Append("War-pig.hog"); AssertFalse(cFileUtil.TouchDir(szDirectory.Text())); szDirectory.Kill(); }
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 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); }
TRISTATE CFileFinder::FindFiles(char* szInDirectory, BOOL bDirs, char* szInName, char* szExtension) { DIR* pDIR; struct dirent* pDirEnt; char szFindName[MAX_PATH]; char szTemp[MAX_PATH]; BOOL bValid; char szDirectory[MAX_PATH]; char szFile[MAX_PATH]; char* szFileExtension; int iStatus; struct stat sBuffer; BOOL bDir; CFileUtil cFileUtil; if (!cFileUtil.FullPath(szDirectory, szInDirectory, MAX_PATH)) { return TRIERROR; } pDIR = opendir(szDirectory); if (pDIR == NULL) { return TRITRUE; } pDirEnt = readdir(pDIR); while (pDirEnt != NULL) { bValid = TRUE; sprintf(szTemp, "%s%s%s", szDirectory, FILE_SEPARATOR, pDirEnt->d_name); iStatus = stat(szTemp, &sBuffer); if (iStatus == -1) { printf("%s: %s\n", strerror(errno), szTemp); return TRIERROR; } bDir = S_ISDIR(sBuffer.st_mode); if (bDir) //Directory { if (bDirs) { if (szInName != NULL) { strcpy(szFile, pDirEnt->d_name); RemoveExtension(szFile); if (StrIStr(szFile, szInName) == NULL) { bValid = FALSE; } } else { bValid = FALSE; } } } else { if (!bDirs) { if (szExtension != NULL) { szFileExtension = FindExtension(pDirEnt->d_name); szFileExtension++; if (StrICmp(szFileExtension, szExtension) != 0) { bValid = FALSE; } } if (szInName != NULL) { strcpy(szFile, pDirEnt->d_name); RemoveExtension(szFile); if (StrIStr(szFile, szInName) == NULL) { bValid = FALSE; } } } else { bValid = FALSE; } } if (bValid) { mcFiles.Add(szTemp, 0); } pDirEnt = readdir(pDIR); } closedir(pDIR); return TRITRUE; }