/[EmuXPortal]/trunk/EmuXPortal/Api/RomParser.cs
ViewVC logotype

Annotation of /trunk/EmuXPortal/Api/RomParser.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 38 - (hide annotations) (download)
Wed Apr 4 07:22:40 2012 UTC (8 years, 6 months ago) by william
File size: 1788 byte(s)
+ speed-up rom parseing by not logging all found roms

1 william 38 //#define LIST_ADDED_ROMS // when defined will log all found rom files
2     using System;
3 william 18 using System.Collections.Generic;
4     using System.Linq;
5     using System.Text;
6     using EmuXPortal.Logging;
7     using System.IO;
8 william 38 using System.Diagnostics;
9 william 18
10     namespace EmuXPortal.Api
11     {
12     public class RomParser
13     {
14 william 29 public RomParser(IEmuConfig config)
15 william 18 {
16 william 29 List<string> roms = GetRoms(config.EmuRomPath, config.Extenstions);
17 william 18 logger.WriteLine("Found {0} Roms", roms.Count);
18 william 29 this.Roms = GenerateRomConfig(roms,config);
19 william 18 }
20     public List<IRomConfig> Roms { get; private set; }
21     private List<string> GetRoms(string path, string searchPattern)
22     {
23 william 38 logger.WriteLine("Searching for Roms in Folder: {0}", path);
24     List<string> roms = (searchPattern == "*.*")
25     ? new List<string>(Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
26 william 26 : new List<string>(Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(s => searchPattern.Contains(Path.GetExtension(s).ToLower())));
27 william 38 #region LIST_ADDED_ROMS
28     #if LIST_ADDED_ROMS
29     foreach (string rom in roms)
30     {
31     FileInfo fi = new FileInfo(rom);
32     logger.WriteLine("\tAdding: {0}", fi.Name);
33     }
34     #endif
35     #endregion
36 william 18 return roms;
37     }
38 william 29 private List<IRomConfig> GenerateRomConfig(List<string> roms, IEmuConfig config)
39 william 18 {
40     List<IRomConfig> romconfigs = new List<IRomConfig>();
41     logger.WriteLine("Generating Rom Configs");
42 william 29 foreach (string rom in roms) { romconfigs.Add(RomLoader.Load(rom, config)); }
43 william 18 return romconfigs;
44     }
45     }
46     }

  ViewVC Help
Powered by ViewVC 1.1.22