public static string Index(string dir, bool html, IndexerConfig config = null) { var settings = new IndexerAdapter(); if (config == null) config = new IndexerConfig(); config.CollapseFolders = false; config.FolderExpandLevel = 2; settings.LoadConfig(config); config.FolderList.Clear(); settings.GetConfig().SetSingleIndexPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), html ? "temp.html" : "temp.txt")); settings.GetConfig().FolderList.Add(dir); Indexer indexer = null; if (html) { indexer = new TreeNetIndexer(settings); } else { indexer = new TreeWalkIndexer(settings); } return indexer.IndexNow(IndexingMode.IN_ONE_FOLDER_MERGED, false); }
public override string IndexNow(IndexingMode mIndexMode, bool bWriteToFile = true) { TreeWalkIndexer tree = new TreeWalkIndexer(mSettings); bool isMergeFile = mSettings.GetConfig().MergeFiles; bool isRemoveBranches = mSettings.GetConfig().RemoveTreeBranches; for (int i = 0; i <= mSettings.GetConfig().FolderList.Count - 1; i++) { string batFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\temp" + i.ToString() + ".bat"; string CURRENT_DIR = mSettings.GetConfig().FolderList[i]; string TREE_COMMAND = "%windir%\\system32\\tree.com " + tree.getSourceSwitch(CURRENT_DIR) + tree.getAsciiSwitch() + tree.getAddFilesSwitch() + tree.getOutputSwitch(CURRENT_DIR, mIndexMode); using (StreamWriter sw = new StreamWriter(batFilePath)) { sw.WriteLine(TREE_COMMAND); //1.5.3.4 Didn't tag index files created in the same folder witout appending if (mSettings.GetConfig().AddFooter) { if (mIndexMode == IndexingMode.IN_EACH_DIRECTORY | i == mSettings.GetConfig().FolderList.Count - 1 | (isMergeFile == false & mIndexMode == IndexingMode.IN_ONE_FOLDER_MERGED)) { sw.WriteLine(mSettings.getBlankLine(tree.getCurrentIndexFilePath())); sw.WriteLine(mSettings.GetFooterText(tree.getCurrentIndexFilePath(), IndexingEngine.TreeLib, false)); } } sw.WriteLine("DEL " + (char)34 + batFilePath + (char)34); } Process proc = new Process(); proc = mSettings.StartHiddenProcess(batFilePath, true); if (isRemoveBranches) { tree.removeTreeBranches(tree.getCurrentIndexFilePath()); } if (mIndexMode == IndexingMode.IN_EACH_DIRECTORY | i == mSettings.GetConfig().FolderList.Count - 1 | (isMergeFile == false & mIndexMode == IndexingMode.IN_ONE_FOLDER_MERGED)) { if (mSettings.GetConfig().ZipFilesInEachDir) { mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null); } if (mSettings.GetConfig().ZipMergedFile) { mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null); } } if (mIndexMode == IndexingMode.IN_ONE_FOLDER_SEPERATE) { if (mSettings.GetConfig().ZipFilesInOutputDir) { //MsgBox(tree.getCurrentIndexFilePath()) mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null); } } if (proc.HasExited) { this.Progress += 1; this.CurrentDirMessage = "Indexed " + mSettings.GetConfig().FolderList[i]; } } return File.ReadAllText(tree.getCurrentIndexFilePath()); }