private string IndexRootFolderToHtml(string folderPath, StringBuilder sb, bool bAddFooter)
        {
            if (mBooFirstIndexFile)
            {
                sb.AppendLine(Xhtml.GetDocType());
                if (mSettings.GetConfig().CollapseFolders)
                {
                    sb.AppendLine(Xhtml.GetCollapseJs());
                    sb.AppendLine(Xhtml.GetCollapseCss());
                }
                sb.AppendLine(Xhtml.GetCssStyle(mSettings.GetConfig().CssFilePath));

                if (mBooMoreFilesToCome)
                {
                    sb.AppendLine(Xhtml.GetTitle(mSettings.GetConfig().MergedHtmlTitle));
                    mBooMoreFilesToCome = false;
                }
                else
                {
                    string[] c = folderPath.Split(Path.DirectorySeparatorChar);
                    if (c[1].Length == 0)
                    {
                        sb.AppendLine(Xhtml.GetTitle("Index for " + folderPath));
                    }
                    else
                    {
                        sb.AppendLine(Xhtml.GetTitle("Index for " + Path.GetFileName(folderPath)));
                    }
                }

                sb.AppendLine(Xhtml.CloseHead());
                sb.AppendLine(Xhtml.OpenBody());

                mBooFirstIndexFile = false;
            }

            TreeDir rootDir = new TreeDir(folderPath);

            rootDir = Analyze(rootDir.DirectoryPath());

            this.IndexToHtmlFile(rootDir, sb);

            if (bAddFooter)
            {
                sb.AppendLine(Xhtml.OpenDiv());
                sb.AppendLine("<hr />");
                sb.AppendLine(mSettings.GetFooterText(null, IndexingEngine.TreeNetLib, true));
                sb.AppendLine(Xhtml.CloseDiv());
                sb.AppendLine(Xhtml.CloseBody());
            }

            mBooFirstDir = true;

            return(sb.ToString());
        }
Exemple #2
0
        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 (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()));
        }