Debian Codegraph @

codelite-cli/csFindInFilesCommandHandler.cpp

raw
1 #include "csFindInFilesCommandHandler.h"
2 #include "search_thread.h"
3 #include "csManager.h"
4
5 csFindInFilesCommandHandler::csFindInFilesCommandHandler(csManager* manager)
6 : csCommandHandlerBase(manager)
7 {
8 }
9
10 csFindInFilesCommandHandler::~csFindInFilesCommandHandler() {}
11
12 void csFindInFilesCommandHandler::DoProcessCommand(const JSONItem& options)
13 {
14 // Extract the options
15 CHECK_STR_PARAM("path", m_folder);
16 CHECK_STR_PARAM("what", m_what);
17 CHECK_STR_PARAM("mask", m_mask);
18 CHECK_BOOL_PARAM("case", m_case);
19 CHECK_BOOL_PARAM("word", m_word);
20
21 if(m_folder.IsEmpty() || !wxFileName::DirExists(m_folder)) {
22 clERROR() << "Invalid input directory:" << m_folder;
23 return;
24 }
25 if(m_what.IsEmpty()) {
26 clERROR() << "what field is empty";
27 return;
28 }
29
30 // Since we use a background thread to process the data for us
31 // we don't want that the base class will notify-completion until the background thread
32 // has completed the search. We will do it ourself when the search thread complete its task
33 SetNotifyCompletion(false);
34
35 SearchData* req = new SearchData();
36 req->SetExtensions(m_mask);
37 req->SetFindString(m_what);
38 req->SetMatchCase(m_case);
39 req->SetMatchWholeWord(m_word);
40 wxArrayString folders;
41 folders.Add(m_folder);
42 req->SetRootDirs(folders);
43 req->SetOwner(GetSink());
44 SearchThreadST::Get()->Add(req);
45 }