Пример #1
0
        // Group: Prefix Data File Functions
        // __________________________________________________________________________


        /* Function: BuildPrefixDataFile
         */
        public void BuildPrefixDataFile(string prefix, CodeDB.Accessor accessor, CancelDelegate cancelDelegate)
        {
            var keywordEntries = GetPrefixKeywords(prefix, accessor, cancelDelegate);

            if (keywordEntries == null || keywordEntries.Count == 0)
            {
                HTMLBuilder.DeleteOutputFileIfExists(HTMLBuilder.SearchIndex_PrefixDataFile(prefix));
                return;
            }

            SortKeywordEntries(keywordEntries);

            foreach (var keywordEntry in keywordEntries)
            {
                SortTopicEntries(keywordEntry);
                RemoveDuplicateTopics(keywordEntry);
            }

            BuildPrefixDataFileJS(prefix, keywordEntries);

            Path path = HTMLBuilder.SearchIndex_PrefixDataFile(prefix);

            try
            {
                // This will create multiple subdirectories if needed, and will not throw an exception if it already exists.
                // We can't use SearchIndex_DataFolder because we may need a subfolder of it.
                System.IO.Directory.CreateDirectory(path.ParentFolder);
            }
            catch (Exception e)
            {
                throw new Exceptions.UserFriendly(
                          Locale.Get("NaturalDocs.Engine", "Error.CouldNotCreateOutputFolder(name, exception)",
                                     path.ParentFolder, e.Message)
                          );
            }

            System.IO.File.WriteAllText(path, output.ToString());
        }