code:<HR>Code:class Cstr { public: Cstr* pNext; CString FileStr; Cstr() { pNext = NULL; } }; Cstr Head; void addStr(CString Add) { Cstr* pCurrent = &Head; if (Head.FileStr == "") { Head.FileStr = Add; } else { while (pCurrent->pNext) { pCurrent = pCurrent->pNext; } Cstr* temp = pCurrent; pCurrent->pNext = new Cstr; pCurrent = pCurrent->pNext; pCurrent->FileStr = Add; temp->pNext = pCurrent; } } bool isAdded(CString out) { bool found = false; Cstr* pCurrent; pCurrent = &Head; while (pCurrent->pNext != 0 && found == false) { if (out.CompareNoCase(pCurrent->FileStr) == 0) { found = true; } pCurrent= pCurrent->pNext; } return found; } void KillLL() { Cstr* Corpse; Cstr* pCurrent = &Head; pCurrent = pCurrent->pNext; while(pCurrent->pNext) { Corpse = pCurrent; pCurrent = pCurrent->pNext; delete Corpse; } delete pCurrent; } void FindFilesR(CString SearchSpec) { CFileFind Finder; Finder.FindFile(SearchSpec); while(Finder.FindNextFile()) { if (Finder.IsDots()) { continue; } if (Finder.IsDirectory()) { CString Path; Path = Finder.GetFilePath(); Path += "\\*.*"; if(!isAdded((LPCTSTR)Finder.GetFileTitle())) { cout << (LPCTSTR) Finder.GetFileTitle() << "\n"; addStr((LPCTSTR)Finder.GetFileTitle()); } FindFilesR(Path); continue; } if(!isAdded((LPCTSTR)Finder.GetFileTitle())) { cout << (LPCTSTR) Finder.GetFileTitle() << "\n"; addStr((LPCTSTR)Finder.GetFileTitle()); } } if (!Finder.IsDots()) { if (Finder.IsDirectory()) { CString Path; Path = Finder.GetFilePath(); Path += "\\*.*"; if(!isAdded((LPCTSTR)Finder.GetFileTitle())) { cout << (LPCTSTR) Finder.GetFileTitle() << "\n"; addStr((LPCTSTR)Finder.GetFileTitle()); } FindFilesR(Path); } if(!isAdded((LPCTSTR)Finder.GetFileTitle())) { cout << (LPCTSTR) Finder.GetFileTitle() << "\n"; addStr((LPCTSTR)Finder.GetFileTitle()); } } }
If I give it a directory with more than 11,000 files/folders within it and its subfolders I get a stack overflow. Any ideas?