/// <summary>
        /// Creates a collection of <see cref="DriverDetails" /> for drivers in the specified directory, optionally ignoring subdirectories.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="includeAllArchitectures">if set to <c>true</c> include drivers with architectures other than <see cref="LocalArchitecture" />.</param>
        /// <param name="searchOption">Specifies whether to search subdirectories for drivers.</param>
        /// <returns>A collection of <see cref="DriverDetails" /> representing all drivers in the specified directory.</returns>
        public static IEnumerable <DriverDetails> LoadFromDirectory(string path, bool includeAllArchitectures, SearchOption searchOption)
        {
            LogDebug($"Loading drivers from {path}");

            List <DriverDetails> drivers = new List <DriverDetails>();

            foreach (string fileName in Directory.GetFiles(path, "*.inf", searchOption))
            {
                using (DriverInfReader reader = new DriverInfReader(fileName))
                {
                    DriverInfParser parser = new DriverInfParser(reader);
                    DriverInf       inf    = parser.BuildInf();
                    if (inf.Drivers.Any())
                    {
                        if (includeAllArchitectures)
                        {
                            drivers.AddRange(inf.Drivers);
                        }
                        else
                        {
                            drivers.AddRange(inf.Drivers.Where(n => n.Architecture == LocalArchitecture));
                        }
                    }
                }
            }

            LogDebug($"{drivers.Count} drivers loaded.");
            return(drivers);
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DriverInfParser" /> class.
 /// </summary>
 /// <param name="reader">The <see cref="DriverInfReader" /> to get data from.</param>
 public DriverInfParser(DriverInfReader reader)
 {
     _reader = reader;
 }