void CDirstatDoc::PerformUserDefinedCleanup(const USERDEFINEDCLEANUP *udc, CItem *item) throw(CException *) { CWaitCursor wc; CString path= item->GetPath(); bool isDirectory= item->GetType() == IT_DRIVE || item->GetType() == IT_DIRECTORY || item->GetType() == IT_FILESFOLDER; // Verify that path still exists if (isDirectory) { if (!FolderExists(path) && !DriveExists(path)) MdThrowStringExceptionF(IDS_THEDIRECTORYsDOESNOTEXIST, path); } else { ASSERT(item->GetType() == IT_FILE); if (!FileExists(path)) MdThrowStringExceptionF(IDS_THEFILEsDOESNOTEXIST, path); } if (udc->recurseIntoSubdirectories && item->GetType() != IT_FILESFOLDER) { ASSERT(item->GetType() == IT_DRIVE || item->GetType() == IT_DIRECTORY); RecursiveUserDefinedCleanup(udc, path, path); } else { CallUserDefinedCleanup(isDirectory, udc->commandLine, path, path, udc->showConsoleWindow, udc->waitForCompletion); } }
void CDirstatDoc::RecursiveUserDefinedCleanup(const USERDEFINEDCLEANUP *udc, const CString& rootPath, const CString& currentPath) { // (Depth first.) CFileFind finder; BOOL b = finder.FindFile(currentPath + _T("\\*.*")); while(b) { b = finder.FindNextFile(); if((finder.IsDots()) || (!finder.IsDirectory())) { continue; } if(GetWDSApp()->IsVolumeMountPoint(finder.GetFilePath()) && !GetOptions()->IsFollowMountPoints()) { continue; } if(GetWDSApp()->IsFolderJunction(finder.GetFilePath()) && !GetOptions()->IsFollowJunctionPoints()) { continue; } RecursiveUserDefinedCleanup(udc, rootPath, finder.GetFilePath()); } CallUserDefinedCleanup(true, udc->commandLine, rootPath, currentPath, udc->showConsoleWindow, true); }