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); }
/** The test finds an entry in each directory Precondition: the drive is already filled with the right files @param aSelector Configuration in case of manual execution */ LOCAL_C TInt TestFindEntry(TAny* aSelector) { TInt i = 100; TInt testStep ; Validate(aSelector); test.Printf(_L("#~TS_Title_%d,%d: Find entry last.txt, TFindFile\n"), gTestHarness, gTestCase); testStep = 1; while(i <= KMaxFiles) { if(i == 100 || i == 1000 || i == 5000 || i == 10000) FindFile1(i, testStep++); i += 100; } gTestCase++; test.Printf(_L("#~TS_Title_%d,%d: Find entry last.txt, RFile::Open \n"), gTestHarness, gTestCase); i = 100; testStep = 1; while(i <= KMaxFiles) { if(i == 100 || i == 1000 || i == 5000 || i == 10000) FindFile2(i, testStep++); i += 100; } gTestCase++; return(KErrNone); }
// --------------------------------------------------------------------------- void __fastcall TForm1::InitMenu() { Screen->Cursor = crHourGlass; btnApply->Enabled = false; // TIcon *icon = new TIcon(); // icon->LoadFromResourceName((unsigned int)HInstance, L"icnIcon"); popCom->Items->Clear(); if (TDirectory::Exists(edtDirectory->Text)) { if (chbSort->Checked) { FindFile2(popCom->Items, edtDirectory->Text); } else { FindFile(popCom->Items, edtDirectory->Text); } } else { ShowMessage("Directory does not exists"); } TMenuItem *item = new TMenuItem(popCom); item->Caption = "-"; popCom->Items->Add(item); item = new TMenuItem(popCom); item->Name = "pumRestore"; item->Caption = "&Restore"; item->Default = true; item->OnClick = RestoreClick; popCom->Items->Add(item); item = new TMenuItem(popCom); item->Name = "pumExit"; item->Caption = "E&xit"; item->OnClick = ExitClick; popCom->Items->Add(item); Screen->Cursor = crDefault; btnApply->Enabled = true; }