void SyGAddRecentFile ( const JCharacter* fullname ) { JString recentDir; JString filename; JString path; if (SyGGetRecentFileDirectory(&recentDir) && JSplitPathAndName(fullname, &path, &filename)) { const JString recentFile = JCombinePathAndName(recentDir, filename); if (JNameUsed(recentFile)) { JRemoveFile(recentFile); JCreateSymbolicLink(fullname, recentFile); return; } // remove oldest links such that only kRecentFileCount - 1 remain JDirInfo* info; if (JDirInfo::Create(recentDir, &info)) { JBoolean changed = kJFalse; JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { if (info->GetEntry(i).IsBrokenLink()) { JRemoveFile(info->GetEntry(i).GetFullName()); changed = kJTrue; } } if (changed) { info->ForceUpdate(); } count = info->GetEntryCount(); if (count >= kRecentFileCount) { info->ChangeSort(JDirEntry::CompareModTimes, JOrderedSetT::kSortDescending); for (JIndex i=count; i>=kRecentFileCount; i--) { JRemoveFile(info->GetEntry(i).GetFullName()); } } // add new entry JCreateSymbolicLink(fullname, recentFile); } } }
void JVMGetSourceFileList::ScanDirectory ( const JCharacter* path ) { JDirInfo* info; if (!JDirInfo::Create(path, &info)) { return; } JXFileListTable* table = (GetFileList())->GetTable(); const JSize count = info->GetEntryCount(); for (JIndex i=1; i<=count; i++) { const JDirEntry& e = info->GetEntry(i); if (e.GetType() == JDirEntry::kFile) { const CBTextFileType fileType = (CMGetPrefsManager())->GetFileType(e.GetName()); if (fileType == kCBJavaSourceFT) { table->AddFile(e.GetFullName()); } } else if (e.GetType() == JDirEntry::kDir) { ScanDirectory(e.GetFullName()); } } delete info; }
void CBNewProjectSaveFileDialog::BuildTemplateMenuItems ( const JCharacter* path, const JBoolean isUserPath, JPtrArray<JString>* menuText, const JCharacter* templateFile, JString** menuTextStr ) const { JDirInfo* info = NULL; if (JDirInfo::Create(path, &info)) { info->ShowDirs(kJFalse); const JSize count = info->GetEntryCount(); JString fullName, templateType; for (JIndex i=1; i<=count; i++) { fullName = (info->GetEntry(i)).GetFullName(); if (CBProjectDocument::GetProjectTemplateType(fullName, &templateType)) { JString* s = jnew JString((info->GetEntry(i)).GetName()); assert( s != NULL ); if (isUserPath) { *s += kUserTemplateMarker; } else { *s += kSysTemplateMarker; } menuText->InsertSorted(s); // save item corresponding to initial template selection if (JSameDirEntry(templateFile, fullName)) { *menuTextStr = s; } } } } }
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 JSearchSubdirs_private ( const JCharacter* startPath, const JCharacter* name, const JBoolean isFile, const JBoolean caseSensitive, JString* path, JString* newName, JProgressDisplay& pg, JBoolean* cancelled ) { // checking this way covers partial path cases like "X11/Xlib.h" const JString fullName = JCombinePathAndName(startPath, name); if (( isFile && JFileExists(fullName)) || (!isFile && JDirectoryExists(fullName))) { const JBoolean ok = JGetTrueName(startPath, path); assert( ok ); if (newName != NULL) { *newName = name; } return kJTrue; } JDirInfo* info; if (!JDirInfo::Create(startPath, &info)) { return kJFalse; } JBoolean found = kJFalse; const JSize count = info->GetEntryCount(); // check each entry (if case sensitive, the initial check is enough) if (!caseSensitive) { for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); if ((( isFile && entry.IsFile()) || (!isFile && entry.IsDirectory())) && JStringCompare(name, entry.GetName(), caseSensitive) == 0) { const JBoolean ok = JGetTrueName(startPath, path); assert( ok ); if (newName != NULL) { *newName = entry.GetName(); } found = kJTrue; break; } if (!pg.IncrementProgress()) { *cancelled = kJTrue; break; } } } // recurse on each directory if (!found && !(*cancelled)) { for (JIndex i=1; i<=count; i++) { const JDirEntry& entry = info->GetEntry(i); if (entry.IsDirectory() && !entry.IsLink()) { const JString& newPath = entry.GetFullName(); if (JSearchSubdirs_private(newPath, name, isFile, caseSensitive, path, newName, pg, cancelled)) { found = kJTrue; break; } } if (*cancelled || (caseSensitive && !pg.IncrementProgress())) { *cancelled = kJTrue; break; } } } delete info; return found; }