public static void Mainly() { DirectoryWalker.DoWalk( PrintDir, PrintFile, ".."); }
public bool HasNextIndexable() { do { while (file_enumerator == null || !file_enumerator.MoveNext()) { if (!dir_enumerator.MoveNext()) { dir_enumerator = null; indexer.Queryable.Indexing = false; return(false); } if (Shutdown.ShutdownRequested) { return(false); } current_dir = (DirectoryInfo)dir_enumerator.Current; num_dir_crawled++; num_file_in_dir = DirectoryWalker.GetNumItems(current_dir.FullName); num_file_in_dir_crawled = 0; indexer.Progress = (double)num_dir_crawled / num_dirs; Log.Info("Scanning {0} maildir mails in {1}", num_file_in_dir, current_dir.FullName); files_to_parse = DirectoryWalker.GetFileInfos(current_dir); file_enumerator = files_to_parse.GetEnumerator(); } num_file_in_dir_crawled++; CrawlFile = (FileInfo)file_enumerator.Current; } while (IsUpToDate(CrawlFile.FullName)); return(true); }
/// <summary> /// Walks the specified directory and locates any fonts files in there /// and loads them /// </summary> /// <param name="directory">Root diretory to start from</param> /// <param name="wildCard">matching wild cards to look for</param> private static void loadFontsFromDir(String directory, String wildCard) { var walker = new DirectoryWalker(directory, wildCard); Log.Debug("Walking dir " + directory); walker.Walk(new OnFileFoundDelegate(onFileFound)); }
public static void Delete(DirectoryInfo dirInfo) { var walker = DirectoryWalker.Create(new DeleteRecursively()); walker.FollowSymbolicLinks = true; walker.Walk(dirInfo); }
public SourceCodeCounter(DirectoryPath rootDir, params string[] excludeFileNames) { this.RootDir = rootDir; excludeFileNames._DoForEach(x => ExcludeHashSet.Add(x)); DirectoryWalker walk = new DirectoryWalker(RootDir.FileSystem); walk.WalkDirectory(RootDir.PathString, (pathInfo, entities, cancel) => { foreach (FileSystemEntity entity in entities) { if (entity.IsDirectory == false && entity.Name._IsExtensionMatch(Consts.Extensions.Filter_SourceCodes)) { if (ExcludeHashSet.Contains(entity.Name) == false) { int numLines = Fs.ReadStringFromFile(entity.FullPath)._GetLines().Length; this.NumLines += numLines; this.NumFiles++; this.TotalSize += entity.Size; } } } return(true); }, exceptionHandler: (pathInfo, err, cancel) => { return(true); }); }
public async Task <IEnumerable <StorageFile> > GetStorageFilesInFolderAsync(StorageFolder folder) { //Get query options with which we search for files in the specified folder var options = DirectoryWalker.GetQueryOptions(); /* * options.FileTypeFilter.Add(".mp3"); * options.FileTypeFilter.Add(".wav"); * options.FileTypeFilter.Add(".ogg"); * options.FileTypeFilter.Add(".flac"); * options.FileTypeFilter.Add(".m4a"); * options.FileTypeFilter.Add(".aif"); * options.FileTypeFilter.Add(".wma");*/ //this is the query result which we recieve after querying in the folder StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(options); //'count' is for total files got after querying. uint count = await queryResult.GetItemCountAsync(); //the event for files changed queryResult.ContentsChanged += QueryResult_ContentsChanged; if (count == 0) { string error = "No songs found!"; BLogger.Logger.Error("No songs were found!"); await SharedLogic.NotificationManager.ShowMessageAsync(error); return(null); } return(await queryResult.GetFilesAsync()); }
static private void CopyDirectoryRecursively(DirectoryInfo source_directory, DirectoryInfo target_directory) { if (!target_directory.Exists) { target_directory.Create(); } foreach (FileInfo source_file in DirectoryWalker.GetFileInfos(source_directory)) { FileInfo target_file = new FileInfo(Path.Combine(target_directory.FullName, source_file.Name)); // FIXME: Don't hard code filenames - Mono.Posix.StatMode.Regular if (source_file.Name.IndexOf("socket") != -1 || source_file.Name.EndsWith("-journal")) { continue; } File.Copy(source_file.FullName, target_file.FullName, true); } foreach (DirectoryInfo source_child_directory in DirectoryWalker.GetDirectoryInfos(source_directory)) { DirectoryInfo target_child_directory = new DirectoryInfo(Path.Combine(target_directory.FullName, source_child_directory.Name)); CopyDirectoryRecursively(source_child_directory, target_child_directory); } }
public void Crawl() { log_files.Clear(); Queue pending = new Queue(); pending.Enqueue(log_dir); while (pending.Count > 0) { string dir = (string)pending.Dequeue(); foreach (string subdir in DirectoryWalker.GetDirectories(dir)) { pending.Enqueue(subdir); } foreach (FileInfo file in DirectoryWalker.GetFileInfos(dir)) { if (FileIsInteresting(file)) { log_files.Add(file); } } } }
/// <summary> /// Recursively walks through the directory and discovers the TTS /// Engine DLL's in there and loads their Types into the cache /// </summary> /// <param name="dir">dir to descend into</param> /// <param name="culture">culture (optional) of the TTS Engine</param> /// <param name="resursive">true if deep-descend</param> private void loadTTSEngineTypesIntoCache(String dir, String culture, bool resursive = true) { DirectoryWalker walker = new DirectoryWalker(dir, "*.dll"); _dirWalkCurrentCulture = culture; walker.Walk(new OnFileFoundDelegate(onFileFound)); }
public bool HasNextIndexable() { do { while (file_enumerator == null || !file_enumerator.MoveNext()) { if (!directory_enumerator.MoveNext()) { Logger.Log.Debug("KonqQ: Crawling done"); file_enumerator = null; current_file = null; return(false); } DirectoryInfo current_dir = (DirectoryInfo)directory_enumerator.Current; //Logger.Log.Debug ("Trying dir:" + current_dir.Name); // start watching for new files and get the list of current files // kind of race here - might get duplicate files if (Inotify.Enabled) { Inotify.Subscribe(current_dir.FullName, OnInotifyEvent, Inotify.EventType.Create | Inotify.EventType.MovedTo); } file_enumerator = DirectoryWalker.GetFileInfos(current_dir).GetEnumerator(); } current_file = (FileInfo)file_enumerator.Current; //if (!IsUpToDate (current_file.FullName)) // Logger.Log.Debug (current_file.FullName + " is not upto date"); // KDE4 cache contains _freq files which are non-cache files } while (current_file.FullName.EndsWith("_freq") || IsUpToDate(current_file.FullName)); return(true); }
/** * Add watch to the parameter directory and its subdirs, recursively */ public void Watch(string path) { DirectoryInfo root = new DirectoryInfo(path); if (!root.Exists) { return; } Queue queue = new Queue(); queue.Enqueue(root); while (queue.Count > 0) { DirectoryInfo dir = queue.Dequeue() as DirectoryInfo; if (!dir.Exists) { continue; } //log.Debug ("Adding inotify watch to " + dir.FullName); Inotify.Subscribe(dir.FullName, OnInotifyEvent, Inotify.EventType.Create | Inotify.EventType.Delete | Inotify.EventType.MovedFrom | Inotify.EventType.MovedTo); foreach (DirectoryInfo subdir in DirectoryWalker.GetDirectoryInfos(dir)) { queue.Enqueue(subdir); } } }
private void Crawl() { directory_enumerator = DirectoryWalker.GetDirectoryInfos(konq_cache_dir).GetEnumerator(); Scheduler.Task crawl_task = NewAddTask(this); crawl_task.Tag = crawler_tag; ThisScheduler.Add(crawl_task); }
public void IsDirTreeWalked_ReturnFalse() { DirectoryInfo rootDirInfo = new DirectoryInfo(Directory.GetCurrentDirectory() + "xxx"); var result = DirectoryWalker.WalkDirectoryTree(rootDirInfo, false); Assert.False(result, "Directory tree could not be walked"); }
/// <summary> /// Walks the specified directory (rescursively) /// to look for files /// </summary> /// <param name="dir">Directory to walk</param> /// <param name="resursive">Recursively search?</param> private static void load(String dir, bool resursive = true) { var walker = new DirectoryWalker(dir, "*.*"); Log.Debug("Walking dir " + dir); walker.Walk(new OnFileFoundDelegate(onFileFound)); }
public void IsDirTreeWalked_ReturnTrue() { Console.WriteLine(Directory.GetCurrentDirectory()); DirectoryInfo rootDirInfo = new DirectoryInfo(Directory.GetCurrentDirectory()); var result = DirectoryWalker.WalkDirectoryTree(rootDirInfo, false); Assert.True(result, "Directory tree could be walked"); }
public bool HasNextIndexable() { if (note_files == null) { note_files = DirectoryWalker.GetFileInfos(tomboy_dir).GetEnumerator(); } return(note_files.MoveNext()); }
public bool HasNextIndexable() { if (map_files == null) { map_files = DirectoryWalker.GetFileInfos(lab_dir).GetEnumerator(); } return(map_files.MoveNext()); }
/// <summary> /// Add folder to Library asynchronously. /// </summary> /// <param name="queryResult">The query result after querying in a specific folder.</param> /// <returns></returns> public static async Task <IEnumerable <Mediafile> > GetSongsFromFolderAsync(StorageFolder folder, bool useIndexer = true, uint stepSize = 20) { StorageFileQueryResult queryResult = folder.CreateFileQueryWithOptions(DirectoryWalker.GetQueryOptions(null, useIndexer)); uint index = 0; IReadOnlyList <StorageFile> files = await queryResult.GetFilesAsync(index, stepSize); index += stepSize; var count = await queryResult.GetItemCountAsync(); if (count <= 0) { BLogger.I("No songs found."); await SharedLogic.Instance.NotificationManager.ShowMessageAsync("No songs found! Please try again."); return(null); } var tempList = new List <Mediafile>((int)count); short progress = 0; try { // Note that I'm paging in the files as described while (files.Count != 0) { var fileTask = queryResult.GetFilesAsync(index, stepSize).AsTask(); for (int i = 0; i < files.Count; i++) { if (files[i]?.IsAvailable == true) { progress++; Messenger.Instance.NotifyColleagues(MessageTypes.MsgUpdateSongCount, progress); Mediafile mp3File = await TagReaderHelper.CreateMediafile(files[i], false).ConfigureAwait(false); //the core of the whole method. if (mp3File != null) { mp3File.FolderPath = Path.GetDirectoryName(files[i].Path); await SaveSingleFileAlbumArtAsync(mp3File, files[i]).ConfigureAwait(false); SharedLogic.Instance.NotificationManager.ShowStaticMessage(progress + "\\" + count + " Song(s) Loaded"); tempList.Add(mp3File); } } } files = await fileTask; index += stepSize; } } catch (Exception ex) { string message = ex.Message + "||" + ex.InnerException; BLogger.E("Error while importing folder.", ex); await SharedLogic.Instance.NotificationManager.ShowMessageAsync(message); } return(tempList.DistinctBy(f => f.OrginalFilename)); }
public ModEntityData <T> ProcessDirectoryHelper(ModEntityData <T> previous, StellarisDirectoryHelper directoryHelper, ModEntityData <Tech> techs) { var directoryPath = GetDirectory(directoryHelper); if (Directory.Exists(directoryPath)) { var result = new ModEntityData <T>(directoryHelper, previous); var techFiles = DirectoryWalker.FindFilesInDirectoryTree(directoryPath, ParseFileMask, IgnoreFiles); Log.Logger.Debug("Directory {directory} produced files {files}", directoryPath, techFiles); var parsedTechFiles = CWParserHelper.ParseParadoxFiles(techFiles.Select(x => x.FullName).ToList(), true); foreach (var(file, cwNode) in parsedTechFiles) { Log.Logger.Debug("Processing file {file}", file); // top level nodes are files, so we process the immediate children of each file, which is the individual techs. foreach (var node in cwNode.Nodes) { try { var entity = Construct(node); Initialise(entity, file, directoryHelper.ModName, directoryHelper.ModGroup, node); SetVariables(entity, node); if (ShouldInclude(entity)) { result[entity.Id] = entity; } else { Log.Logger.Debug("File {file} contained node {key} was processed, but failed the include filter so is discarded", file, entity.Id); } } catch (Exception e) { if (AbortOnFailure) { throw new Exception($"Error Processing node {node.Key} in file: {file}", e); } Log.Logger.Error(e, "Error Processing node {node} in file: {file}", node.Key, file); } } } // special case for managing techs // techs are their own tech lookup. var latestTechData = result as ModEntityData <Tech>; if (latestTechData != null) { AddLinks(result, latestTechData); } else { AddLinks(result, techs); } return(result); } Log.Logger.Debug("{mod} did not have {directory}", directoryHelper.ModName, directoryPath.Replace(directoryHelper.Root, "")); return(previous); }
override protected void DoTaskReal() { DirectoryModel dir; lock (big_lock) { if (to_be_crawled.Count == 0) { DoneCrawling(); return; } dir = to_be_crawled.Dequeue() as DirectoryModel; if (FileSystemQueryable.Debug) { Log.Debug("Running tree crawl task"); } SetIsActive(true, dir); } LuceneQueryable queryable = (LuceneQueryable)Source; if (dir.IsAttached) { if (FileSystemQueryable.Debug) { Logger.Log.Debug("Scanning '{0}' for subdirectories", dir.FullName); } try { foreach (string name in DirectoryWalker.GetDirectoryNames(dir.FullName)) { string path; path = Path.Combine(dir.FullName, name); if (!FileSystem.IsSpecialFile(path)) { handler(dir, name); } } } catch (DirectoryNotFoundException ex) { Logger.Log.Debug("Couldn't scan '{0}' for subdirectories", dir.FullName); } } lock (big_lock) { if (to_be_crawled.Count != 0) { Reschedule = true; } else { DoneCrawling(); } } }
void backgroundWorkerSearch_DoWork(object sender, DoWorkEventArgs e) { DirectoryWalker directoryWalk = new DirectoryWalker(this.textBoxSearchPath.Text); directoryWalk.FileProcessed += new EventHandler <DirectoryWalkEventArgs>(directoryWalk_FileProcessed); directoryWalk.FileAccessed += new EventHandler <DirectoryWalkEventArgs>(directoryWalk_FileAccessed); directoryWalk.DirectoryWalkComplete += new EventHandler <DirectoryWalkEventArgs>(directoryWalk_DirectoryWalkComplete); Collection <ProcessedFileInfo> duplicates = directoryWalk.WalkDirectory(); e.Result = duplicates; }
/** * To check if the path represents a kmail directory: * for all directories and files named "ddd" and not starting with a '.', * there should be matching index file named .ddd.index * Ignore zero length files; zero-length mbox files might not have index files. */ private bool GuessLocalFolder(string path, bool verbose) { if (!Directory.Exists(path)) { return(false); } if (verbose) { Log.Debug("Checking if {0} is kmail local mail directory ?", path); } bool no_content = true; foreach (string entry in DirectoryWalker.GetItemNames(path, null)) { if (entry.StartsWith(".")) { continue; } // Ignore zero size mbox files string fullpath = Path.Combine(path, entry); if (File.Exists(fullpath)) { FileInfo fi = new FileInfo(fullpath); if (fi.Length == 0) { continue; } } // index-file name is of pattern .name.index string indexfile = Path.Combine(path, "." + entry + ".index"); if (!File.Exists(indexfile)) { if (verbose) { Log.Warn(String.Format( "KMail backend: No index file for {0}." + "Ignoring {1}, probably not a kmail directory.", fullpath, path)); } return(false); } else { no_content = false; } } return(!no_content); }
private void CrawlProtocolDirectory(string proto_dir, bool index) { if (Inotify.Enabled) { Inotify.Subscribe(proto_dir, OnInotifyNewAccount, Inotify.EventType.Create); } // Walk through accounts foreach (string account_dir in DirectoryWalker.GetDirectories(proto_dir)) { CrawlAccountDirectory(account_dir, index); } }
private Dictionary <string, string> ParseScriptedVariables(string scriptedVariableDir) { var techFiles = DirectoryWalker.FindFilesInDirectoryTree(scriptedVariableDir, StellarisDirectoryHelper.TextMask); var parsedTechFiles = CWParserHelper.ParseParadoxFiles(techFiles); var result = new Dictionary <string, string>(); foreach (var file in parsedTechFiles.Values) { // top level nodes are files, so we process the immediate children of each file, which is the individual variables. AddAdditionalFileVariables(file); } return(result); }
public void FindDuplicates(Options commandLineOptions) { DirectoryWalker duplicateWalker = new DirectoryWalker(commandLineOptions.Items[0]); if (commandLineOptions.progressIndicator) { duplicateWalker.FileProcessed += new EventHandler <DirectoryWalkEventArgs>(duplicateWalker_FileProcessed); duplicateWalker.DirectoryWalkComplete += new EventHandler <DirectoryWalkEventArgs>(duplicateWalker_DirectoryWalkComplete); } Collection <ProcessedFileInfo> duplicateFiles = duplicateWalker.WalkDirectory(); WriteResults(duplicateFiles, commandLineOptions.csvOutput); }
public static void Main(string[] args) { DirectoryWalker dw = new DirectoryWalker( new DirectoryWalker.ProcessDirCallback(PrintDir), new DirectoryWalker.ProcessFileCallback(PrintFile)); string root = "."; if (args.Length == 1) { root = args[0]; } dw.Walk(root, "Passed string object"); }
public bool HasNextIndexable() { if (metadata != null) { if (metadata.MoveNext()) { return(true); } else { metadata = null; FileAttributesStore.AttachLastWriteTime((string)metafiles.Current, DateTime.UtcNow); } } while (metadata == null) { if (metafiles == null) { metafiles = DirectoryWalker.GetItems(nautilus_dir, is_xml_file).GetEnumerator(); } if (!metafiles.MoveNext()) { return(false); } string file = (string)metafiles.Current; if (FileAttributesStore.IsUpToDate(file)) { continue; } metadata = NautilusTools.GetMetadata((string)metafiles.Current).GetEnumerator(); if (metadata.MoveNext()) { return(true); } else { metadata = null; FileAttributesStore.AttachLastWriteTime(file, DateTime.UtcNow); } } return(false); // Makes the compiler happy }
public DirectoryIndexableGenerator(FileSystemQueryable queryable, DirectoryModel directory) { this.queryable = queryable; this.directory = directory; if (this.directory == null) { done = true; } else { files = DirectoryWalker.GetFileInfos(this.directory.FullName).GetEnumerator(); } }
private void Crawl(bool index) { //queryable.IsIndexing = true; if (Inotify.Enabled) { Inotify.Subscribe(logs_dir, OnInotifyNewProtocol, Inotify.EventType.Create); } // Walk through protocol subdirs foreach (string proto_dir in DirectoryWalker.GetDirectories(logs_dir)) { CrawlProtocolDirectory(proto_dir, index); } }
public static async Task ConvertFolderAsync(string sourcePath, string targetPath, ILogger logger) { try { var fs = new FileSystem(); var options = new Dictionary <string, object>(); var typeAnalysis = new AnalyzerImpl(fs, logger, options, DateTime.Now); typeAnalysis.Analyze(sourcePath); typeAnalysis.Finish(); var types = new TypeReferenceTranslator(typeAnalysis.BuildTypeDictionary()); var walker = new DirectoryWalker(fs, sourcePath, "*.py"); await walker.EnumerateAsync(state => { foreach (var file in fs.GetFiles(state.DirectoryName, "*.py", SearchOption.TopDirectoryOnly)) { var path = fs.GetFullPath(file); var xlator = new Translator( state.Namespace, fs.GetFileNameWithoutExtension(file), fs, logger); var module = typeAnalysis.GetAstForFile(path); var relativePath = MakeRelative(sourcePath, path); var targetFilePath = Path.ChangeExtension(MakeAbsolute(targetPath, relativePath), ".py.cs"); var targetFileDirectory = Path.GetDirectoryName(targetFilePath); if (!Directory.Exists(targetFileDirectory)) { Directory.CreateDirectory(targetFileDirectory); } xlator.TranslateModuleStatements( module.body.stmts, types, targetFilePath); } }); logger.Inform(Resources.Done); } catch (Exception ex) { logger.Error(Resources.ErrUnexpectedConversionError, ex.Message); logger.Inform(Resources.ConversionWasAborted); } }
private void buttonGenerate_Click(object sender, EventArgs e) { catalogList.Clear(); DialogResult res = saveFileDialog1.ShowDialog(); if (res != DialogResult.OK) { return; } labelStatus.Text = "Location helper code, adding in files..."; Filename = saveFileDialog1.FileName; DirectoryWalker dw = new DirectoryWalker( new DirectoryWalker.ProcessDirCallback(PrintDir), new DirectoryWalker.ProcessFileCallback(PrintFile)); dw.Walk(SelectedPath, "*.aspx,*.ascx,*.master,*.cs"); labelStatus.Text = "POT file preparing..."; if (catalogList.Count > 0) { GeneratePOTFile(); } labelStatus.Text = "POT file generated!.."; }