//--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- void __fastcall TDialogProjectNew::BuildTreeView(TTreeView *TreeView, TTreeNode *TreeNode, const String Path) { TSearchRec SearchRec; if (FindFirst(Path + "\\*.*", faAnyFile, SearchRec) == 0) { do { if (SearchRec.Name[1] != '.') { if (SearchRec.Attr & faDirectory) { TTreeNode *TreeNode2 = TreeView->Items->AddChild(TreeNode, SearchRec.Name); TreeNode2->ImageIndex = 2; TreeNode2->SelectedIndex = 2; BuildTreeView(TreeView, TreeNode2, Path + "\\" + SearchRec.Name); } } } while (FindNext(SearchRec) == 0); FindClose(SearchRec); } if (FindFirst(Path + "\\*.*", faAnyFile, SearchRec) == 0) { do { if (SearchRec.Name[1] != '.') { if (!(SearchRec.Attr & faDirectory)) { TTreeNode *TreeNode2 = TreeView->Items->AddChild(TreeNode, SearchRec.Name); TreeNode2->ImageIndex = 1; TreeNode2->SelectedIndex = 1; } } } while (FindNext(SearchRec) == 0); FindClose(SearchRec); } }
int UnitTest::RunAllInGroup( const char* group ) { printf( "GROUP %s\n", group ); int error_count = 0; const char dashes[] = "------------------------------"; // Because of (naughty) reliance of static constructor to register tests, the order in the list is out of my // control. A little extra code to make them run in alphabetical order. UnitTest* test = FindNext( group, NULL ); while( test ) { size_t offset = strlen( test->m_Name ); if( offset >= sizeof( dashes ) ) { offset = sizeof( dashes ) - 1; } printf( " %s %s ", test->m_Name, dashes + offset ); test->m_ErrorCount = 0; test->Test(); if( test->m_ErrorCount == 0 ) { printf( "pass\n" ); } error_count += test->m_ErrorCount; test->m_Done = true; test = FindNext( group, test ); } return error_count; }
LRESULT EditFind::FindReplaceCmd(WPARAM, LPARAM lParam) { FindReplaceDialog* dialog = FindReplaceDialog::GetNotifier(lParam); ASSERT(dialog == m_dialog); bool found = true; if (dialog->IsTerminating()) { m_lastFind = dialog->GetFindString(); m_searchDown = dialog->SearchDown(); m_matchCase = dialog->MatchCase(); m_matchWholeWord = dialog->MatchWholeWord(); m_dialog = NULL; } else if (dialog->FindNext()) { found = FindNext(true); if (!found) found = FindNext(false); } else if (dialog->ReplaceCurrent()) found = Replace(); else if (dialog->ReplaceAll()) found = ReplaceAll(); if (!found) ::MessageBeep(MB_ICONEXCLAMATION); return 0; }
void __fastcall TForm1::FindFile2(TMenuItem *parent, String path) { TSearchRec sr; if (FindFirst(TPath::Combine(path, "*.*"), faDirectory, sr) == 0) { do { if (sr.Name == "." || sr.Name == ".." || sr.Attr != faDirectory) continue; TMenuItem *item = AddMenu(parent, sr, TPath::Combine(path, sr.Name)); if (sr.Attr & faDirectory && chbSubDirectory->Checked) { FindFile2(item, TPath::Combine(path, sr.Name)); } } while (!FindNext(sr)); } if (FindFirst(TPath::Combine(path, edtPattern->Text), faAnyFile, sr) == 0) { do { if (sr.Name == "." || sr.Name == ".." || sr.Attr & faDirectory) continue; AddMenu(parent, sr, TPath::Combine(path, sr.Name)); } while (!FindNext(sr)); } FindClose(sr); }
bool ClassBrowser::RecursiveSearch(const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& parent, wxTreeItemId& result) { if (!parent.IsOk() || !tree) return false; // first check the parent item if (FoundMatch(search, tree, parent)) { result = parent; return true; } wxTreeItemIdValue cookie; wxTreeItemId child = tree->GetFirstChild(parent, cookie); if (!child.IsOk()) return RecursiveSearch(search, tree, FindNext(search, tree, parent), result); while (child.IsOk()) { if (FoundMatch(search, tree, child)) { result = child; return true; } if (tree->ItemHasChildren(child)) { if (RecursiveSearch(search, tree, child, result)) return true; } child = tree->GetNextChild(parent, cookie); } return RecursiveSearch(search, tree, FindNext(search, tree, parent), result); }
//@Override ECode FindActionModeCallback::OnActionItemClicked( /* [in] */ IActionMode* mode, /* [in] */ IMenuItem* item, /* [out] */ Boolean* result) { if (mWebView == NULL) { //throw new AssertionError( // "No WebView for FindActionModeCallback::onActionItemClicked"); assert(0); } AutoPtr<IBinder> binder; assert(0); // mWebView->GetWebView()->GetWindowToken((IBinder**)&binder); mInput->HideSoftInputFromWindow(binder, 0, NULL); Int32 id; item->GetItemId(&id); switch(id) { case R::id::find_prev: FindNext(FALSE); break; case R::id::find_next: FindNext(TRUE); break; default: if (result) *result = FALSE; return NOERROR; } if (result) *result = TRUE; return NOERROR; }
bool MoonPhases::Test( ) { bool ok = true; cout << "Testing MoonPhases" << endl; double jan2000 = DateTime( 1, January, 2000, 0, 0 ).JulianDay( ); TESTCHECKFE( FindNext( jan2000, New ), DateTime( 6, January, 2000, 18, 14 ).JulianDay( ), &ok, 2.e-10 ); TESTCHECKFE( FindNext( jan2000, FirstQuarter ), DateTime( 14, January, 2000, 13, 34 ).JulianDay( ), &ok, 2.e-10 ); TESTCHECKFE( FindNext( jan2000, Full ), DateTime( 21, January, 2000, 4, 40 ).JulianDay( ), &ok, 2.e-10 ); TESTCHECKFE( FindNext( jan2000, LastQuarter ), DateTime( 28, January, 2000, 7, 57 ).JulianDay( ), &ok, 2.e-10 ); if ( ok ) cout << "MoonPhases PASSED." << endl << endl; else cout << "MoonPhases FAILED." << endl << endl; return ok; }
void FindAndReplace::OnReplaceButton(LPFINDREPLACE& lpfr) { CharacterRange crange; CharacterRange crtextrange; if(m_havefound) { ReplaceOnce(lpfr->lpstrFindWhat, lpfr->lpstrReplaceWith); m_havefound = FindNext(lpfr->lpstrFindWhat, (wyBool)(!(lpfr->Flags & FR_DOWN)), (wyBool)(lpfr->Flags & FR_WHOLEWORD), (wyBool)(lpfr->Flags & FR_MATCHCASE)); } else { crange = GetSelection(); pGlobals->m_findcount = 0; ::SendMessage (m_hwndedit, SCI_SETSEL, crange.cpMin, crange.cpMin); m_havefound = FindNext(lpfr->lpstrFindWhat, (wyBool)(!(lpfr->Flags & FR_DOWN)), (wyBool)(lpfr->Flags & FR_WHOLEWORD), (wyBool)(lpfr->Flags & FR_MATCHCASE)); crtextrange = GetSelection(); //checking whether the selected text is same as text to be replaced. //if it is not same, then we are selecting the text,then on next replace click we will replace the text. //if it is same then we will replace the text. if(m_havefound && crtextrange.cpMin == crange.cpMin && crtextrange.cpMax == crange.cpMax ) { //replace the selected text ReplaceOnce(lpfr->lpstrFindWhat, lpfr->lpstrReplaceWith); // Find the next given text m_havefound = FindNext(lpfr->lpstrFindWhat, (wyBool)(!(lpfr->Flags & FR_DOWN)), (wyBool)(lpfr->Flags & FR_WHOLEWORD), (wyBool)(lpfr->Flags & FR_MATCHCASE)); } } //if text not found if(m_havefound == wyFalse) { NotFoundMsg(lpfr->lpstrFindWhat); return; } return; }
HtmlNode GetNode(std::istream& io_is) { //get name std::string node_name = GetString('>', io_is); if(!FindNext('>', io_is)) { throw std::logic_error("no >"); } auto pos = io_is.tellg(); //get childs std::vector<HtmlNode> node_childs; while(FindNext('<', io_is) && io_is.peek() != '/') { node_childs.push_back(GetNode(io_is)); pos = io_is.tellg(); } io_is.seekg(pos); //get text std::string node_text; if(node_childs.empty()) { //get text node_text = GetString('<', io_is); } if(!FindNext('<', io_is)) { throw std::logic_error("no <"); } if(!FindNext('/', io_is)) { throw std::logic_error("no /"); } //get closed name std::string node_close_name = GetString('>', io_is); if(!FindNext('>', io_is)) { throw std::logic_error("no >"); } if(node_close_name != node_name) { throw std::logic_error("invalid close name"); } HtmlNode node(node_name, node_text, node_childs); return node; }
/* Starts enumeration process. */ CHXDirectory::FSOBJ CHXDirectory::FindFirst(const char* szPattern, char* szPath, UINT16 nSize) { OSErr err; CHXDirSpecifier dirSpec(m_strPath); require(dirSpec.IsSet() && CHXFileSpecUtils::DirectoryExists(dirSpec), bail); // if there is already an iterator, dispose it if (m_FSIterator) { err = FSCloseIterator(m_FSIterator); check_noerr(err); m_FSIterator = 0; } err = FSOpenIterator((FSRef *) dirSpec, kFSIterateFlat, &m_FSIterator); require_noerr(err, bail); m_strFindPattern = szPattern; return FindNext(szPath, nSize); bail: return FSOBJ_NOTVALID; }
LRESULT ViewFilesDialog::OnFindDialogMessage(WPARAM wParam, LPARAM lParam) { /* * Handle activity in the modeless "find" dialog. */ assert(fpFindDialog != NULL); fFindDown = (fpFindDialog->SearchDown() != 0); fFindMatchCase = (fpFindDialog->MatchCase() != 0); fFindMatchWholeWord = (fpFindDialog->MatchWholeWord() != 0); if (fpFindDialog->IsTerminating()) { LOGI("VFD find dialog closing"); fpFindDialog = NULL; return 0; } if (fpFindDialog->FindNext()) { fFindLastStr = fpFindDialog->GetFindString(); FindNext(fFindLastStr, fFindDown, fFindMatchCase, fFindMatchWholeWord); } else { LOGI("Unexpected find dialog activity"); } return 0; }
bool EditFind::ReplaceAll(void) { ASSERT(m_findOnly == false); // Does the current selection match? bool currentMatch = false; { CHARRANGE sel = m_edit->GetSelect(); CStringW selText = m_edit->GetTextRange(sel.cpMin,sel.cpMax); if (m_dialog->MatchCase()) { if (selText.Compare(m_dialog->GetFindString()) == 0) currentMatch = true; } else { if (selText.CompareNoCase(m_dialog->GetFindString()) == 0) currentMatch = true; } } if (currentMatch || FindNext(true)) { while (Replace()); return true; } return false; }
//--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- __fastcall TDialogProjectNew::TDialogProjectNew(TComponent* Owner) : TForm(Owner) { TemplatePath = Usul()->Ini->ReadString("Settings", "PathTemplatesProjects", TemplatePath = Usul()->Path + "\\Templates\\Projects"); PageControl->ActivePageIndex = 0; TSearchRec SearchRec; if (FindFirst(TemplatePath + "\\*", faDirectory, SearchRec) == 0) { do { if (SearchRec.Name[1] != '.') { TListItem *ListItem = ListView->Items->Add(); ListItem->Caption = SearchRec.Name; ListItem->ImageIndex = 1; } } while (FindNext(SearchRec) == 0); } FindClose(SearchRec); if (Usul()->HasWriteAccessToExeDirectrory()) Edit->Text = Usul()->Path + "\\New project"; else Edit->Text = Usul()->PathDocuments + "\\New project"; for (int I = 2;;I++) { bool IsDirectoryExists = DirectoryExists(Edit->Text); bool IsFileExists = FileExists(Edit->Text); if (!IsDirectoryExists && !IsFileExists) break; Edit->Text = Usul()->Path + "\\New project" + String(I); } }
bool FileFind::FindFirst(std::string &name) { #ifdef WIN32 mInternalFind->hFindNext = FindFirstFileA(mSearchName, &mInternalFind->finddata); if ( mInternalFind->hFindNext == INVALID_HANDLE_VALUE ) return false; mInternalFind->bFound = 1; // have an initial file to check. return FindNext(name); #endif #ifdef LINUX_GENERIC mInternalFind->mDir = opendir("."); return FindNext(name); #endif //return false; }
// Generates a list of files in the root directory on the card void GenerateFileList() { SearchRec file; int i; // Reset vars g_FilesInList = 0; // All file types except for directories unsigned char Attributes = ATTR_HIDDEN | ATTR_SYSTEM | ATTR_READ_ONLY | ATTR_VOLUME| ATTR_ARCHIVE; if(FindFirst("*.*", Attributes, &file) == 0)// 0 is success { g_FilesInList = 1; strcpy(g_FileNames[0], file.filename); g_FileLengths[0] = file.filesize; for(i=1; i < MAX_FILENAMES; i++) { if(FindNext(&file) == 0) { strcpy(g_FileNames[i], file.filename); g_FileLengths[i] = file.filesize; } else break; g_FilesInList++; } } }
bool t4p::FinderClass::FindPrevious(const UnicodeString& text, int32_t start) { bool found = false; if (t4p::FinderClass::EXACT == Mode) { ResetLastHit(); found = FindPreviousExact(text, start, true); } else if (t4p::FinderClass::CASE_INSENSITIVE == Mode) { ResetLastHit(); found = FindPreviousExact(text, start, false); } else { // lazy way of backwards searching, search from the beginning until // we find the last hit before start int32_t position = 0, length = 0, nextPosition = 0, nextLength = 0; while (FindNext(text, nextPosition + nextLength)) { if (GetLastMatch(nextPosition, nextLength)) { if ((nextPosition + nextLength) >= start && start > 0) { break; } found = true; position = nextPosition; length = nextLength; } } IsFound = found; if (IsFound) { LastPosition = position; LastLength = length; } } return IsFound; }
// Try to load the resource DLL from [each directory in %PATH%]/<lcid>/ static void *LoadSearchPath(const MyString &resourceDllName, LocalizedFileHandler lfh) { void *hmod = NULL; // Get the PATH variable into a C++ string MyString envPath; if (ClrGetEnvironmentVariable("PATH", envPath)) return hmod; MyStringIterator endOfChunk, startOfChunk = StrBeginIter(envPath); MyString tryPath; for (SkipChars(envPath, startOfChunk, W(' '), W(';')); hmod == NULL && startOfChunk != StrEndIter(envPath); SkipChars(envPath, startOfChunk, W(' '), W(';'))) { // copy this chunk of the path into our trypath endOfChunk = startOfChunk; FindNext(envPath, endOfChunk, W(';')); MakeString(tryPath, envPath, startOfChunk, endOfChunk); // Don't try invalid locations if (IsEmptyStr(tryPath) || CharLength(tryPath) >= _MAX_PATH) continue; // Try to load the dll hmod = LoadLocalFile(tryPath, resourceDllName, lfh); startOfChunk = endOfChunk; } return hmod; }
CFile *CNTFSDirectory::FindFirst(const wstring &name, int attribs) { if ( !isvalid() ) return NULL; // Reset FindReset(); CStream *rootstream = m_file.openstream(m_ir_attribnum, false); if ( !rootstream ) return NULL; NTFSindexroot *indexroot = NTFSindexroot::Read(rootstream); delete rootstream; if ( !indexroot ) return NULL; CBlockStream *indexnodestream = NULL; int blocksize = 0; if ( indexroot->islargeindex() ) { indexnodestream = m_file.openstream(m_ia_attribnum, false); if ( !indexnodestream ) { free(indexroot); return NULL; } blocksize = indexnodestream->PhysicalBlockSize(); } bool result = read(m_ntfs, indexnodestream, &indexroot->indexentries, indexroot->indexnodesize, blocksize, name, attribs); free(indexroot); if ( indexnodestream ) { delete indexnodestream; indexnodestream = NULL; } return result ? FindNext(name, attribs) : NULL; }
void MainWindow::initialActions() { initialActionsIcons(); initialActionsShortcuts(); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openDocumentAction())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveDocumentAction())); connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAsDocumentAction())); connect(ui->actionProperties, SIGNAL(triggered()), this, SLOT(propertiesAction())); connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeDocumentAction())); connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(ui->actionCopy, SIGNAL(triggered()), this, SLOT(copyNodeAction())); connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(findAction())); connect(ui->actionFindNext, SIGNAL(triggered()), findWidget, SLOT(FindNext())); connect(ui->actionFindPrevious, SIGNAL(triggered()), findWidget, SLOT(FindPrevious())); // bookmarks connect(ui->actionBookmark, SIGNAL(triggered()), this, SLOT(bookmarkToggled())); connect(ui->actionBookmarkGotoNext, SIGNAL(triggered()), model, SLOT(bookmarkNext())); connect(ui->actionBookmarkGotoPrevious, SIGNAL(triggered()), model, SLOT(bookmarkPrev())); // view connect( ui->actionCollapseAll, SIGNAL(triggered()), this, SLOT(collapseAll()) ); connect( ui->actionExpandAll, SIGNAL(triggered()), this, SLOT(expandAll()) ); // FIXME: it's a temporary ui->actionNew->setVisible( false ); }
CFile* CFSCobraDEVIL::FindFirst(char* pattern) { findIdx = 0; strcpy(DEVIL_FindPattern, pattern); return FindNext(); }
void SearchPanel::InitSearch(const wxString& searchtext, bool replace) { wxWindow* focus_win = FindFocus(); if (focus_win == replaceBox) { if (replace) Replace(); else searchbox->SetFocus(); return; } if (!replace && focus_win == searchbox) { FindNext(); return; } nosearch = true; if (!searchtext.empty()) { searchbox->SetValue(searchtext); nextButton->Enable(); prevButton->Enable(); replaceButton->Enable(); allButton->Enable(); } nosearch = false; SetState(cxFOUND); if (replace) { replaceBox->SetSelection(-1, -1); // select all replaceBox->SetFocus(); } else { searchbox->SetSelection(-1, -1); // select all searchbox->SetFocus(); } }
HRESULT AbstractDeviceContent::RemoveObjectsMarkedForDeletion( ACCESS_SCOPE Scope) { HRESULT hr = S_OK; DWORD dwIndex = 0; AbstractDeviceContent* pChild = NULL; CComCritSecLock<CComAutoCriticalSection> Lock(m_ChildrenCS); while (FindNext(Scope, dwIndex, &pChild)) { if (pChild != NULL) { hr = pChild->RemoveObjectsMarkedForDeletion(Scope); CHECK_HR(hr, "Failed to remove children marked for deletion for object '%ws'", pChild->ObjectID); if ((hr == S_OK) && (pChild->MarkedForDeletion == true)) { m_Children.RemoveAt(dwIndex); delete pChild; pChild = NULL; } } dwIndex++; } m_Children.FreeExtra(); return hr; }
int CzString::Find(const char* string) { FindIndex = 0; int index = FindNext(string); FindIndex = 0; return index; }
/***************************************************************************** * Sort * * Will sort the list according to setting. The sort method is bubble sort as * we deal with a linked list and only know the current, previous and next * object at any time. It is also perfect for sorting as we add one by * one items. * * Sorting on non-containers are not possible as we have no idea as to how * to compare. As for sorting we expect one iteration since this should be * called after each Add... ****************************************************************************/ void List::Sort() { bool bMore=true; ListNode *n=NULL; ListNode *n2; Object *o1=NULL; Object *o2; int c; if(!m_bContainer) return; switch(m_eSort) { case Nosort: break; case Ascending: while(bMore) { bMore=false; n=NULL; o1 = FindFirst(&n); n2=n; while(o1!=NULL && (o2=FindNext(&n))!=NULL) { c = o1->Compare(o2); if(c==-1) { Swap(&n2,&n); bMore=true; } n2=n; o1=o2; } } break; case Descending: while(bMore) { bMore=false; n=NULL; o1 = FindLast(&n); n2=n; while(o1!=NULL && (o2=FindPast(&n))!=NULL) { c = o1->Compare(o2); if(c==-1) { Swap(&n2,&n); bMore=true; } n2=n; o1=o2; } } break; } }
//************************************************************************************** //*** asCARD_FindNext //*** //*** returns 0 if file found //************************************************************************************** int asCARD_FindNext() { // this is not really failsafe... if(gCardState&CARD_MOUNTED) return FindNext(&CardRec); else return -1; }
int32 Next() { if (!this->HasNext()) return 0; int32 item_current = this->item_next; FindNext(); return item_current; }
// "Find Next Pref" context menu command selected. void CPrefEditView::OnFindNextPref() { // If FindFirst not done before FindNext, call FindFirst first. if (m_hNextFind == NULL) OnFindPref(); else FindNext(); }
// Find a pref containing a string in one of its fields. BOOL CPrefEditView::FindFirst(CString& rstrFind) { CTreeCtrl &treeCtrl = GetTreeCtrl(); m_hNextFind = treeCtrl.GetRootItem(); m_strFind = rstrFind; return FindNext(); }
int32 Next() { if (this->IsEnd()) return 0; int32 item_current = this->item_next; FindNext(); return item_current; }
void DialogSpellChecker::OnAdd(wxCommandEvent&) { spellchecker->AddWord(from_wx(orig_word->GetValue())); // Remember the word that was last added LastAdded = orig_word->GetValue(); FindNext(); }