public TreeNetIndexer(IndexerAdapter settings)
     : base(settings)
 {
     mSettings = new IndexerAdapter();
     mSettings = settings;
     mFilter = new FilterHelper(mSettings);
 }
Exemple #2
0
        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 TreeWalkIndexer(IndexerAdapter myReader)
     : base(myReader)
 {
     this.mSettings = myReader;
     if (this.mSettings.GetConfig().IndexFileExt.Contains("html"))
     {
         this.mSettings.GetConfig().IndexFileExt = ".txt";
     }
 }
Exemple #4
0
 public List<TreeFile> GetFilesColl(IndexerAdapter settings)
 {
     List<TreeFile> files = new List<TreeFile>();
     files.AddRange(GetFilesColl());
     FilterHelper filter = new FilterHelper(settings);
     foreach (TreeFile f in GetFilesColl())
     {
         if (filter.IsBannedFile(f.GetFilePath()))
         {
             files.Remove(f);
         }
     }
     return files;
 }
        private void IndexInEachDir(IndexerAdapter myReader)
        {
            string where = null;
            List<string> folderList = new List<string>();
            folderList = myReader.GetConfig().FolderList;
            TreeNetIndexer treeNetLib = new TreeNetIndexer(myReader);

            string ext = myReader.GetConfig().IndexFileExt;

            for (int i = 0; i <= myReader.GetConfig().FolderList.Count - 1; i++)
            {
                string strDirPath = myReader.GetConfig().FolderList[i];
                // 2.5.1.1 Indexer halted if a configuration file had non-existent folders paths
                if (Directory.Exists(strDirPath))
                {
                    where = myReader.fGetIndexFilePath(i, IndexingMode.IN_EACH_DIRECTORY);
                    if (Directory.Exists(Path.GetDirectoryName(where)) == false)
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(where));
                    }

                    StreamWriter sw = new StreamWriter(where, false);
                    StringBuilder sb = new StringBuilder();
                    try
                    {
                        this.CurrentDirMessage = "Indexing " + strDirPath;

                        if (ext.Contains("html"))
                        {
                            //MessageBox.Show(myReader.GetConfig().mCssFilePath)
                            treeNetLib.mBooFirstIndexFile = true;
                            treeNetLib.IndexRootFolderToHtml(strDirPath, sb, mSettings.GetConfig().AddFooter);
                        }
                        else
                        {
                            treeNetLib.IndexFolderToTxt(strDirPath, sb, mSettings.GetConfig().AddFooter);
                        }

                        this.Progress += 1;
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        MessageBox.Show(ex.Message + "\n" + "Please Run TreeGUI As Administrator or Change Output Directory.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK);
                        return;
                    }
                    finally
                    {
                        sw.Write(sb.ToString());
                        sw.Close();
                    }

                    // Zip after sw is closed
                    if (myReader.GetConfig().ZipFilesInEachDir)
                    {
                        myReader.ZipAdminFile(where, null);
                    }
                }
            }
        }
Exemple #6
0
 public FilterHelper(IndexerAdapter settings)
 {
     mSettings = settings;
     mBannedFilter = Regex.Split(mSettings.GetConfig().IgnoreFilesList, "\\" + mSettings.GetOptions().IgnoreFilesListDelimiter);
 }
 public Indexer(IndexerAdapter settings)
 {
     mSettings = settings;
 }