void CBFileListTable::ScanDirectory ( const JString& origPath, const JBoolean recurse, const JPtrArray<JString>& allSuffixList, CBSymbolList* symbolList, CBCTree* cTree, CBJavaTree* javaTree, JProgressDisplay& pg ) { JString path; JDirInfo* info; if (!JGetTrueName(origPath, &path) || !JDirInfo::Create(path, &info)) { return; } const JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); // If it's a directory, recurse. if (entry.IsDirectory() && recurse && !entry.IsLink() && !JIsVCSDirectory(entry.GetName())) { ScanDirectory(entry.GetFullName(), recurse, allSuffixList, symbolList, cTree, javaTree, pg); } // If it's a file ending in one of the suffixes, parse it. else if (entry.IsFile()) { JString trueName = entry.GetFullName(); time_t modTime = entry.GetModTime(); if (entry.IsWorkingLink()) { const JBoolean ok = JGetTrueName(entry.GetFullName(), &trueName); assert( ok ); const JError err = JGetModificationTime(trueName, &modTime); assert( err.OK() ); } ParseFile(trueName, allSuffixList, modTime, symbolList, cTree, javaTree); } pg.IncrementProgress(); } delete info; }
JBoolean CBSearchTextDialog::SearchDirectory ( const JString& path, const JRegex* fileRegex, const JRegex* pathRegex, JPtrArray<JString>* fileList, JPtrArray<JString>* nameList, JProgressDisplay& pg ) const { JDirInfo* info; if (!JDirInfo::Create(path, &info)) { return kJTrue; // user didn't cancel } info->SetWildcardFilter(const_cast<JRegex*>(fileRegex), kJFalse, itsInvertFileFilterCB->IsChecked()); JBoolean keepGoing = kJTrue; const JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); if (entry.IsFile()) { if (!pg.IncrementProgress()) { keepGoing = kJFalse; break; } SaveFileForSearch(entry.GetFullName(), fileList, nameList); } else if (itsRecurseDirCB->IsChecked() && entry.IsDirectory() && !entry.IsLink() && !JIsVCSDirectory(entry.GetName())) { JBoolean match = kJTrue; if (pathRegex != NULL) { match = ! pathRegex->Match(entry.GetName()); } if (match && !SearchDirectory(entry.GetFullName(), fileRegex, pathRegex, fileList, nameList, pg)) { keepGoing = kJFalse; break; } } } jdelete info; return keepGoing; }
JBoolean JDirInfo::IsVisible ( const JDirEntry& entry ) const { const JDirEntry::Type type = entry.GetType(); const JString& name = entry.GetName(); if (!itsShowHiddenFlag && name.GetFirstCharacter() == '.' && name != "..") { return kJFalse; } if (!itsShowVCSDirsFlag && JIsVCSDirectory(name)) { return kJFalse; } if (type == JDirEntry::kDir || type == JDirEntry::kDirLink) { return JI2B(itsShowDirsFlag && (!itsFilterDirsFlag || MatchesNameFilter(entry)) && MatchesDirEntryFilter(entry)); } else if (type == JDirEntry::kFile || type == JDirEntry::kFileLink || type == JDirEntry::kBrokenLink) { return JI2B(itsShowFilesFlag && MatchesNameFilter(entry) && MatchesDirEntryFilter(entry)); } else if (type == JDirEntry::kUnknown || type == JDirEntry::kUnknownLink) { return JI2B(itsShowOthersFlag && MatchesNameFilter(entry) && MatchesDirEntryFilter(entry)); } else if (type == JDirEntry::kDoesNotExist) { return kJFalse; } else { assert( 0 ); // this should never happen return kJFalse; } }