public void TestFindReferences_CreateObject() { string fileName = "C:/WebRoot/Test.cfm"; string testContent = @"<cfset variables.foo = createObject(""component"", ""CFC.Foo"") /> <cfset variables.bar=CREATEOBJECT(""component"",""CFC.Bar"")/> <cfset variables.cat = createObject('component', 'CFC.Cat').init() />"; _fileSystem.AddFile(fileName, new MockFileData(testContent)); const string fooFile = "C:/Components/CFC/Foo.cfc"; const string barFile = "C:/Components/CFC/Bar.cfc"; const string catFile = "C:/Components/CFC/Cat.cfc"; _fileSystem.AddFile(fooFile, MockFileData.NullObject); _fileSystem.AddFile(barFile, MockFileData.NullObject); _fileSystem.AddFile(catFile, MockFileData.NullObject); var fileSearcher = new FileSearcher(_fileSystem, "C:/WebRoot"); fileSearcher.AddRootDirectory("C:/Components"); var file = new CodeFile(fileName, _fileSystem); List <CodeFile> references = file.GetReferences(fileSearcher); var fooCodeFile = new CodeFile(fooFile, _fileSystem); var barCodeFile = new CodeFile(barFile, _fileSystem); var catCodeFile = new CodeFile(catFile, _fileSystem); Assert.AreEqual(3, references.Count); Assert.IsTrue(fooCodeFile.Equals(references[0])); Assert.IsTrue(barCodeFile.Equals(references[1])); Assert.IsTrue(catCodeFile.Equals(references[2])); }
private void stopSearchButton_Click(object sender, EventArgs e) { changeState(Transition.Stop); searcher.Cancel().ContinueWith((task) => { searcher = null; files.Clear(); });//don't clear until the task is completely stopped/canceled }
public void Execute(InterpreterItem item, Keys modifiers) { string command = item.Desciption; bool test = true; try { test = _mutex.WaitOne(0, true); } catch { } if (test) { if ((modifiers & Keys.Shift) == Keys.Shift) { command = FileSearcher.GetItemFolder(command); } try { ProcessStartInfo info = new ProcessStartInfo(command); info.UseShellExecute = true; info.ErrorDialog = true; System.Diagnostics.Process.Start(info); info = null; } catch (Exception e) { MessageBox.Show(e.Message); } _mutex.ReleaseMutex(); } }
public static void Main(string[] args) { string line; List <string> shares = new List <string>(); string sharesFile = args[0]; int maxThreads = Int32.Parse(args[1]); string outFile = args[2]; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(args[0]); while ((line = file.ReadLine()) != null) { line = line.Split('\t')[0].Trim(); if (!line.Contains("$") && !line.Contains("NETLOGON") && !line.Contains("SYSVOL")) { shares.Add(line); } } file.Close(); FileSearcher fSearcher = new FileSearcher(maxThreads, outFile); fSearcher.ProcessShares(shares); }
/// <summary> /// マークダウンファイル検索 /// </summary> /// <returns></returns> private static IEnumerable <ArticleContent> ReadArticles(string path, bool isDraft, bool isShowMarkdownFilePath) { return(FileSearcher .EnumerateFileInfos(path) .Where(item => PathUtil.EqualsExtension(item.fi.Extension, ".md")) .Select(item => new ArticleContent(item.fi, isDraft, isShowMarkdownFilePath))); }
public static FileSearcher XmlFileBySection(this SettingsLoader loader) { var searcher = new FileSearcher(XmlFileSettings.Create); loader.AddHandler <IncludeFileConfig>("IncludeXmlFile", searcher); return(searcher); }
/// <summary> /// Restore the component definitions. /// </summary> /// <exception cref="System.Data.OperationAbortedException"> /// The loading of the component definition was aborted. /// </exception> public void Restore() { // If components are already loaded, GO AWAY DAMN DIALOG -Aeglos 25 Jun 11 if (isLoaded) { return; } // Ensure we have the component definition file before starting the worker thread, or die. if (string.IsNullOrEmpty(saveFilePath)) { saveFilePath = FileSearcher.GetComponentFile(); if (string.IsNullOrEmpty(saveFilePath)) { Report.FatalError("Unable to locate component definition file."); } } else { // Report.Debug("Components file to be loaded: \"" + saveFilePath + "\""); } ProgressDialog progress = new ProgressDialog(); progress.Text = "Loading Components"; ThreadPool.QueueUserWorkItem(new WaitCallback(LoadComponents), progress); progress.ShowDialog(); if (!progress.Success) { Report.FatalError("Failed to load component file: ProgressDialog returned false."); throw new System.Exception(); } isLoaded = true; }
/// <Summary> /// The splash screen and launcher application for starting Nova. Nova should /// normally be started by running the NovaLauncher. /// </Summary> public NovaLauncher() { InitializeComponent(); // Show the Nova version string version = Application.ProductVersion; string[] versionParts = version.Split('.'); string productVersion = string.Join(".", versionParts, 0, 3); AssemblyName assemblyName = Assembly.GetExecutingAssembly().GetName(); int buildNumber = assemblyName.Version.Build; int revision = assemblyName.Version.Revision; // DateTime start = new DateTime(2000, 1, 1); // DateTime buildDate = start.Add(new TimeSpan(buildNumber, 0, 0, 2 * revision, 0)); versionNumber.Text = string.Format("{0} - {1}", productVersion, DateTime.Now.ToString("MMM dd yyyy")); // look for a game in progress this.serverStateFile = FileSearcher.GetFile(Global.ServerStateKey, false, "", "", "", false); this.clientStateFile = FileSearcher.GetFile(Global.ClientStateKey, false, "", "", "", false); if (this.serverStateFile == null && this.clientStateFile == null) { continueGameButton.Enabled = false; } }
public void FileSearcher_FindsAMatch_FiresEvents() { const string fileName = "Test"; const string fileContent = "Speedy thing goes in, speedy thing comes out!"; var dataSource = new TestDataSource(fileName, fileContent, Encoding.UTF8); var fileSearcher = new FileSearcher( new Regex("speedy", RegexOptions.None), new[] { dataSource }, false, 0); using var monitor = fileSearcher.Monitor(); fileSearcher.Begin(); fileSearcher.Wait(); monitor.OccurredEvents.Should().Contain(x => x.EventName == nameof(fileSearcher.MatchFound)) .Which.Parameters[1].Should().BeOfType <MatchFoundEventArgs>() .Which.Matches.Should().BeEquivalentTo(new[] { new SearchMatch(1, fileContent, 22, 6, null, null) }); monitor.OccurredEvents.Should().Contain(x => x.EventName == nameof(fileSearcher.Completed)) .Which.Parameters[1].Should().BeOfType <CompletedEventArgs>() .Which.FailureReason.Should().BeNull(); monitor.OccurredEvents.Should().NotContain(x => x.EventName == nameof(fileSearcher.Error)); }
public static FileSearcher JsonFileByExtension(this SettingsLoader loader) { var searcher = new FileSearcher(JsonFileSettings.Create, "js", "json"); loader.AddHandler <IncludeFileConfig>("IncludeFile", searcher); return(searcher); }
/// <summary> /// Handles updating the status of the search and cleans up the memory streams when the /// search finishes. /// </summary> private void mUiUpdateThrottle_Tick(object sender, EventArgs e) { // Flooding the UI will result in slower performance! if (mFileSearcher != null) { lock (mFileSearcher.Stats) { mResults.updateStatus(mFileSearcher.Stats); if (mFileSearcher.Stats.Finished) { writeResultsToTextBox(); mUiUpdateThrottle.Enabled = false; mStreamWriter.Dispose(); mStreamWriter.Close(); mMemoryStream.Dispose(); mMemoryStream.Close(); Settings.get().SearchParams.SearchInProgress = false; DirectoryCache.get().update(DirectoryCache.UpdateType.Automatic, false); mFileSearcher.HandleResults -= fileSearcher_HandleResults; mFileSearcher = null; GC.Collect(); } } } }
public void TestFileSearcher() { Stack <FileInfo> found = FileSearcher.SearchForfiles(new DirectoryInfo(@".\TestInputs")); Assert.IsTrue(found.Where(x => x.Name == "AssemblyInfo.cs").Count() == 2); Assert.IsTrue(found.Where(x => x.Name == "Product.wxs").Count() == 1); }
public ActionResult SearchFiles(FileSearcherViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var searcher = new FileSearcher(); if (!string.IsNullOrEmpty(model.FileSearcherId)) { FileSearchContainer.AddSearcher(model.FileSearcherId, searcher); } try { var result = searcher.SearchFiles(new FileSearcherQuery { SearchString = model.SearchString, TargetDirectory = model.Directory }); model.Files = result.Files.Select(x => x.FullName); } catch (Exception ex) { return(RedirectToAction("BadRequest", "Error")); } finally { if (!string.IsNullOrEmpty(model.FileSearcherId)) { FileSearchContainer.RemoveSearcher(model.FileSearcherId); } } return(View(model)); }
private void FastbootFlasher() { if (!Directory.Exists(swPath)) { Logger.w("sw path is not valid", "Fastboot Flasher:", null); throw new Exception("sw path is not valid"); } try { string[] strArray = FileSearcher.SearchFiles(swPath, flashtype); if (strArray.Length == 0) { Logger.w("can not found file " + Flashtype, "Fastboot Flasher:", null); throw new Exception("can not found file " + Flashtype); } string str = strArray[0]; string command = string.Format("pushd \"{0}\"&&prompt $$&&set PATH=\"{1}\";%PATH%&&\"{2}\" -s {3}&&popd", swPath, XiaomiController.Instance.ResourceDirectory, str, name); Logger.w("Firmware path: " + swPath, "Fastboot Flasher:", null); Logger.w("env android path: " + XiaomiController.Instance.ResourceDirectory, "Fastboot Flasher:", null); Logger.w("Flash Type :" + str, "Fastboot Flasher:", null); Logger.w("Send Command: " + command, "Fastboot Flasher:", null); Command.ProcessReturnOutput(command); } catch (Exception ex) { UpdateDeviceStatus(new float?(), ex.Message, "Error", true); eror = true; } }
public MainWindow() { InitializeComponent(); var fileSearcher = new FileSearcher(); DataContext = new CoreVm(fileSearcher); }
public override void flash() { try { //location of fasboot.exe var fastboot = Script.fastboot; //search flash type (flash_all.bat, flash_all_except_storage.bat) in SW directory var strArray = FileSearcher.SearchFiles(swPath, flashScript); if (strArray.Length == 0) { throw new Exception("can not found file " + flashScript); } var str = strArray[0]; var command = string.Format("pushd \"{0}\"&&prompt $$&&set PATH=\"{1}\";%PATH%&&\"{2}\" -s {3}&&popd", swPath, Script.AndroidPath, str, deviceName); Log.w(deviceName, "image path:" + swPath); //location of Source\\ThirdParty\\Google\\Android Log.w(deviceName, "env android path:" + Script.AndroidPath); //location of bat file Log.w(deviceName, "script :" + str); new Cmd(deviceName).Execute_returnLine(deviceName, command, 1); } catch (Exception ex) { FlashingDevice.UpdateDeviceStatus(deviceName, new float?(), ex.Message, "eror", true); Log.w(deviceName, ex, true); } }
/*******************************************************************************/ public SearchPanel() { InitializeComponent(); fileSearcher = new FileSearcher(); listView.ColumnClick += new ColumnClickEventHandler(ColumnClick); }
public void TestFileSearcher() { var result = FileSearcher.Search(Helper.GetDataPath(), new List <string>() { "Web.config.xslt", "App.config.xslt" }); Assert.AreEqual(result.Count, 3); }
/// <summary> /// Initialize the gameFilesLocationTextBox from the Nova.conf, if any. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param> private void GameFileInflator_Load(object sender, EventArgs e) { string gameFiles = FileSearcher.GetFolder(Global.ClientFolderKey, Global.ClientFolderName); if (!string.IsNullOrEmpty(gameFiles)) { gameFilesLocationTextBox.Text = gameFiles; } }
public MainForm() { InitializeComponent(); unVisible(); SetInitialValuesInTextBoxes(); fileSearcher = new FileSearcher(); fileSearcher.NewFileProcessed += NewFileProcessedMsg; fileSearcher.NewFileFound += NewFileFoundMsg; }
static void Main(string[] args) { // 1. List all font files in the windows directory or any of its subdirectories. foreach (IEntry entry in FileSearcher.Search(@"C:\windows", "*.fon|*.ttf")) { Console.WriteLine(entry.Path); } }
public void TestDetectApplicationFile_None() { string fileName = "C:/Temp/Sub/test.cfm"; var fileSearcher = new FileSearcher(_fileSystem, "C:/Temp"); CodeFile foundAppFile = fileSearcher.GetApplicationFile(fileName); Assert.IsNull(foundAppFile); }
public void RunTaskSearchMatchingFiles() { Console.WriteLine("____________Task Matching Files Searcher____________"); FileSearcher fileSearcher = new FileSearcher(new ConsolePrinter()); Console.WriteLine("Please, enter fragment of file name: "); string nameFromConsole = Console.ReadLine(); fileSearcher.SearchMatchingFiles(nameFromConsole); }
private static void SetupSubscribers(FileSearcher fileSearcher) { fileSearcher.SearchStarted += Visitor_Start; fileSearcher.SearchFinished += Visitor_Finish; fileSearcher.FileFound += Visitor_FileFound; fileSearcher.DirectoryFound += Visitor_DirectoryFound; fileSearcher.FilteredFileFound += Visitor_FilteredFileFound; fileSearcher.FilteredDirectoryFound += Visitor_FilteredDirectoryFound; }
private void startSearchButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(fileExtensionDropDown.Text)) { MessageBox.Show("Please select a file extension from the drop down list."); return; } files.Clear(); changeState(Transition.Run); searcher = new FileSearcher(fileExtensionDropDown.Text.Split(' ')[0]); searcher.NewFilesFound += Searcher_NewFilesFound; searcher.FileSearchCompleted += Searcher_FileSearchCompleted; searcher.RunSearch(); }
public void TestLocateFile_CFC() { var fileSearcher = new FileSearcher(_fileSystem, "C:/Test"); _fileSystem.AddFile("C:/Test/CFC/Foo.cfc", MockFileData.NullObject); CodeFile codeFile = fileSearcher.LocateFile("CFC/Foo.cfc"); var expectedFile = new CodeFile("C:/Test/CFC/Foo.cfc", _fileSystem); Assert.IsTrue(expectedFile.Equals(codeFile)); }
private void FirehoseDownloadImg(string swPath) { string[] strArray1 = FileSearcher.SearchFiles(swPath, SoftwareImage.RawProgramPattern); string[] strArray2 = FileSearcher.SearchFiles(swPath, SoftwareImage.PatchPattern); for (int index = 0; index < strArray1.Length; ++index) { if (WriteFilesToDevice(comm.serialPort.PortName, swPath, strArray1[index])) { ApplyPatchesToDevice(comm.serialPort.PortName, strArray2[index]); } } }
public void IO_FileSearcher() { var pathsToSearch = new List <string>() { Directory.GetCurrentDirectory() }; var maskToSearch = @"app.config"; var searcher = new FileSearcher(pathsToSearch, maskToSearch, 2); searcher.Search(); Assert.IsTrue(searcher.FoundFiles.Count() > 0); }
/// <summary> /// Save: Serialize this component to an <see cref="XmlElement"/>. /// </summary> /// <param name="xmldoc">The parent <see cref="XmlDocument"/>.</param> /// <returns>An <see cref="XmlElement"/> representation of the Property.</returns> public new XmlElement ToXml(XmlDocument xmldoc) { XmlElement xmlelComponent = xmldoc.CreateElement("Component"); xmlelComponent.AppendChild(base.ToXml(xmldoc)); Global.SaveData(xmldoc, xmlelComponent, "Mass", Mass.ToString(System.Globalization.CultureInfo.InvariantCulture)); xmlelComponent.AppendChild(Cost.ToXml(xmldoc)); // Tech xmlelComponent.AppendChild(this.RequiredTech.ToXml(xmldoc)); // Description if (Description != null) { Global.SaveData(xmldoc, xmlelComponent, "Description", Description); } // Race Restrictions xmlelComponent.AppendChild(this.Restrictions.ToXml(xmldoc)); // Image - convert the ImageFile to a relative path, so this program runs in other locations XmlElement xmlelImage = xmldoc.CreateElement("Image"); string graphicsPath = FileSearcher.GetGraphicsPath(); try { XmlText xmltxtImage = xmldoc.CreateTextNode(Global.EvaluateRelativePath(FileSearcher.GetGraphicsPath(), this.ImageFile).Replace(Path.DirectorySeparatorChar, '/')); // Paths are always stored in external files using forward slashes. xmlelImage.AppendChild(xmltxtImage); xmlelComponent.AppendChild(xmlelImage); } catch (Exception) { // could be a null reference (graphicsPath == null) or a file IO Exception // Nova! does not know where the graphics are, they probably have not been loaded. The image location will not be saved. } // Properties foreach (string key in this.Properties.Keys) { XmlElement xmlelPropertyType = xmldoc.CreateElement("Type"); XmlText xmltxtPropertyType = xmldoc.CreateTextNode(key); xmlelPropertyType.AppendChild(xmltxtPropertyType); XmlElement xmlelProperty = this.Properties[key].ToXml(xmldoc); xmlelProperty.AppendChild(xmlelPropertyType); xmlelComponent.AppendChild(xmlelProperty); } return(xmlelComponent); }
public void Find_ShouldNotReturnAnyHitsForAnAbsoluteIncludePattern() { var fileSearcher = new FileSearcher(); var directoryPath = Path.Combine(this.TestResourceDirectory.FullName, "Package"); var includePattern = Path.Combine(directoryPath, "Web.config"); Assert.IsTrue(File.Exists(includePattern)); Assert.IsFalse(fileSearcher.Find(directoryPath, null, new[] { includePattern }).Any()); includePattern = @"C:\Some-directory\Some-file.txt"; Assert.IsFalse(fileSearcher.Find(directoryPath, null, new[] { includePattern }).Any()); }
public List<FileInfo> FindFiles(String data, String directory, int fileBufferize) { try { callerThread = Thread.CurrentThread; FolderSearcher folderSearcher = new FolderSearcher(directory, SetAllFilesSearched, AddToBaseList); folderThread = new Thread(folderSearcher.FindFilesToSearch); folderThread.IsBackground = true; folderThread.Start(); searchThreads = new Thread[threadCount]; for (int i = 0; i < threadCount; i++) { FileSearcher fileSearcher = new FileSearcher( data, fileBufferize, IsAllFilesSearched, GetListCount, AddFileInfo, GetFirstFileInfo ); searchThreads[i] = new Thread(fileSearcher.TestFiles); searchThreads[i].IsBackground = true; searchThreads[i].Start(); } folderThread.Join(); for (int i = 0; i < threadCount; i++) { searchThreads[i].Join(); } return new List<FileInfo>(resultFiles.Values); } catch (ThreadInterruptedException e) { return null; } }
//not a really good search engine public List<SearchItem> Search(string searchString, IUser user) { #region new filesearch try{ DataTable dt = _db.Select("SELECT filename,md5 " + "FROM files"); FileSearcher fs = new FileSearcher(); foreach(DataRow dr in dt.Rows) { DBFile dbfile = new DBFile(); dbfile.Name = dr.ItemArray[0].ToString(); dbfile.MD5 = dr.ItemArray[1].ToString(); fs.Search(dbfile, searchString); } }catch(Exception e) { Debug.WriteLine("Server: New Search. "+e.Message); } #endregion #region thestandard be replaced soon if(!CheckUserIntegrity(user)) return null; if(searchString.Length < 3 || searchString.Length > 50) return null; // search algo gone easy: one hit gets 100% List<SearchItem> si = new List<SearchItem>(); try{ DataTable dt = _db.Select("SELECT user " + "FROM interests " + "WHERE content = '"+searchString+"'"); foreach(DataRow dr in dt.Rows) { SearchItem s = new SearchItem(); s.PercentageHit = 100; s.User = int.Parse(dr.ItemArray[0].ToString()); s.UserLastSeen = DateTime.Now.Ticks; si.Add(s); } }catch(Exception e) { Console.Write(e); } return si; #endregion }