Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        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);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public FilterHelper(IndexerAdapter settings)
 {
     mSettings = settings;
     mBannedFilter = Regex.Split(mSettings.GetConfig().IgnoreFilesList, "\\" + mSettings.GetOptions().IgnoreFilesListDelimiter);
 }