/// <summary>
        /// Returns the markup from the search
        /// of either the public directories
        /// or all directories.
        /// </summary>
        /// <param name="page">
        ///     The page calling this method</param>
        /// <param name="pattern">
        ///     The search pattern</param>
        /// <param name="isRegex">
        ///     Is the pattern a regular expression?</param>
        /// <param name="ignoreCase">
        ///     Ignore case in the search?</param>
        /// <param name="statistics">
        ///     Include file statistics markup?</param>
        /// <param name="download">
        ///     Include download button markup?</param>
        /// <param name="onlyPublic">
        ///     Whether or not to restrict to public directories</param>
        public static string SearchSiteMarkup
            (Page page,
            string pattern,
            bool isRegex,
            bool ignoreCase,
            bool statistics,
            bool download,
            bool onlyPublic)
        {
            StringBuilder builder = new StringBuilder();

            string rootPath = FileTools.GetRoot(page);

            List <string> directoryList =
                SourceTools.MakeDirectoryList(rootPath, onlyPublic);

            List <string> tildeDirectoryList =
                FileTools.GetTildePaths(rootPath, directoryList);

            foreach (string tildeDirectoryPath in tildeDirectoryList)
            {
                string markup =
                    SearchDirectoryMarkup(page, tildeDirectoryPath, pattern,
                                          isRegex, ignoreCase, statistics, download, onlyPublic);

                if (!StringTools.IsTrivial(markup))
                {
                    builder.Append(markup);
                }
            }

            return(builder.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// First converts tildeDirectoryPath to lowercase.
        ///
        /// Then produces the list of tilde directory paths
        /// whose tree roots itself at this base path.
        ///
        /// If there is an error then may return an empty list.
        /// </summary>
        public static List <string> TildeDirectoryPathList
            (HttpServerUtility server, string tildeDirectoryPath)
        {
            List <string> list = AbsoluteDirectoryPathList(server, tildeDirectoryPath);

            if (list.Count == 0)
            {
                return(list);
            }

            string root = server.MapPath("~/");

            return(FileTools.GetTildePaths(root, list));
        }
        /// <summary>
        /// Returns the markup from the search
        /// of either the public directories
        /// or all directories that start at
        /// tildeDirectoryPath.
        /// </summary>
        /// <param name="page">
        ///     The page calling this method</param>
        /// <param name="tildeDirectoryPath">
        ///     The root of the directory tree to search</param>
        /// <param name="pattern">
        ///     The search pattern</param>
        /// <param name="isRegex">
        ///     Is the pattern a regular expression?</param>
        /// <param name="ignoreCase">
        ///     Ignore case in the search?</param>
        /// <param name="statistics">
        ///     Include file statistics markup?</param>
        /// <param name="download">
        ///     Include download button markup?</param>
        /// <param name="onlyPublic">
        ///     Whether or not to restrict to public directories</param>
        public static string SearchTreeMarkup
            (Page page,
            string tildeDirectoryPath,
            string pattern,
            bool isRegex,
            bool ignoreCase,
            bool statistics,
            bool download,
            bool onlyPublic)
        {
            StringBuilder builder = new StringBuilder();

            int n = tildeDirectoryPath.Length;

            if (tildeDirectoryPath[n - 1] != SourceTools.slash)
            {
                tildeDirectoryPath = tildeDirectoryPath + SourceTools.slash;
            }

            string directoryPath = page.MapPath(tildeDirectoryPath);

            string rootPath = FileTools.GetRoot(page);

            List <string> directoryList =
                SourceTools.MakeDirectoryList(directoryPath, onlyPublic);

            List <string> tildeDirectoryList =
                FileTools.GetTildePaths(rootPath, directoryList);

            foreach (string tdp in tildeDirectoryList)
            {
                string markup =
                    SearchDirectoryMarkup(page, tdp, pattern,
                                          isRegex, ignoreCase, statistics, download, onlyPublic);

                if (!StringTools.IsTrivial(markup))
                {
                    builder.Append(markup);
                }
            }

            return(builder.ToString());
        }