/// <summary> /// root method for the search operation /// </summary> private void search() { List <string> files = new List <string>(); //start searching from the root path searchDirectory(currentSearchData.getPath(), files); //clear state searching = false; currentSearchData = null; searchThread = null; //pass results through the callback if (fileMatchedCallback != null) { finishedCallback(files); } }
/// <summary> /// starts searching the files inside the path for the given signature names. /// </summary> /// <param name="path">path to search</param> /// <param name="signaturesToSearch">signature names the search inside a file</param> /// <param name="searchSubDirectories">will this search include the subdirectories?</param> /// <param name="maxBytesToCheck">how many bytes are going to be read in a file to match signature name? needs to be kept small</param> /// <returns>true if search started</returns> public bool start(string path, List <string> signaturesToSearch, bool searchSubDirectories = false, int maxBytesToCheck = 20) { bool canStart = !searching; if (canStart) { uppercaseStrings(signaturesToSearch); abortSearch = false; searching = true; currentSearchData = new SearchData(path, signaturesToSearch, searchSubDirectories, maxBytesToCheck); //start searching files in a new thread ThreadStart ts = new ThreadStart(search); searchThread = new Thread(ts); searchThread.Start(); } return(canStart); }