std::string getActorClassInfoMapList() { std::string resultList(""); for (unsigned int i = 0; i < 1024; ++i) { if (s_actorClassInfoList[i]) { resultList += ","; resultList += s_actorClassInfoList[i]->GetClassName(); } else break; } return resultList; }
void FindWindow::FindResults(void) { // This function is called from the FinderThread function, so locking is // required when accessing any member variables. Lock(); bool canReplace = fReplaceButton->IsEnabled(); EnableReplace(false); for (int32 i = fResultList->CountItems() - 1; i >= 0; i--) { // We don't want to hog the window lock, but we also don't want // tons of context switches, either. Yielding the lock every 5 items // should give us sufficient responsiveness. if (i % 5 == 0) { Unlock(); Lock(); } BListItem *item = fResultList->RemoveItem(i); delete item; } Unlock(); ShellHelper shell; shell << "cd "; shell.AddEscapedArg(fWorkingDir); shell << "; pwd; find . -type f "; shell << "|xargs grep -n -H -s --binary-files=without-match "; // TODO check for PCRE invocation and pass in pcre flag to grep if so // TODO Ensure RE escaping also happens (E.g. open/close paran etc.) shell.AddEscapedArg(fFindBox->Text()); if (fThreadQuitFlag) return; BString out; shell.RunInPipe(out, false); if (fThreadQuitFlag) return; BObjectList<BString> resultList(20, true); TokenizeToList(out.String(), resultList); Lock(); for (int32 i = 0; i < resultList.CountItems(); i++) { // We don't want to hog the window lock, but we also don't want // tons of context switches, either. Yielding the lock every 5 items // should give us sufficient responsiveness. if (i % 5 == 0) { Unlock(); Lock(); } BString entryString(resultList.ItemAt(i)->String()); BString filename(entryString); int32 pos = filename.FindFirst(":"); if (pos < 0) continue; filename.Truncate(pos); if (filename.StartsWith("./")) filename.Remove(0,2); STRACE(2,("Truncated file name from grep: %s\n",filename.String())); BString lineString; entryString.CopyInto(lineString, pos + 1, entryString.CountChars() - pos); int32 pos2 = lineString.FindFirst(":"); BString locationString; lineString.CopyInto(locationString, pos2 + 1, lineString.CountChars() - pos2); lineString.Truncate(pos2); DPath entryPath(fWorkingDir); entryPath << filename; BString fullPath(fWorkingDir); fullPath << "/" << filename; STRACE(2,("Full path: %s\n",fullPath.String())); DPath relPath(filename); fResultList->AddItem(new GrepListItem(fullPath,filename, entryPath.GetRef(), atol(lineString.String()), locationString.String())); } EnableReplace(true); if (fResultList->CountItems() == 0) fResultList->AddItem(new BStringItem(B_TRANSLATE("No matches found"))); Unlock(); }