コード例 #1
0
ファイル: Category.cs プロジェクト: rcarz/fusion
 /// <summary>
 /// Initialises the category.
 /// </summary>
 /// <param name="catdir">the category directory</param>
 /// <param name="tree">the ports tree this category belongs to</param>
 private Category(DirectoryInfo catdir, AbstractTree tree)
 {
     _catdir = catdir;
     _tree = tree;
     _packages = new List<IPackage>(Package.Enumerate(this));
 }
コード例 #2
0
ファイル: Category.cs プロジェクト: rcarz/fusion
        /// <summary>
        /// Scans the ports directory for categories.
        /// </summary>
        /// <param name="tree">the ports tree to associate categories with</param>
        /// <param name="portdir">the ports directory to scan</param>
        /// <returns>a list of categories found in the ports directory</returns>
        private static List<Category> Enumerate(AbstractTree tree, DirectoryInfo portdir)
        {
            Configuration xmlconf = Configuration.LoadSeries();
            FileInfo[] filearr = xmlconf.ProfilesRootDir.GetFiles("categories");
            string[] list = (filearr.Length > 0) ?
                File.ReadAllLines(filearr[0].FullName) :
                new string[] { };

            DirectoryInfo[] diarr = portdir
                .EnumerateDirectories()
                .Where(d => d.Name.Length <= 20 &&
                            Category.ValidateName(d.Name) &&
                            list.Contains(d.Name))
                .ToArray();
            _log.DebugFormat(
                "categories: {0}",
                String.Join(", ", diarr.Select(i => i.Name).ToArray()));
            List<Category> results = new List<Category>();

            foreach (DirectoryInfo di in diarr)
                results.Add(new Category(di, tree));

            return results;
        }