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

Contents of /trunk/EmuXPortal/Api/PlatformParser.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Wed Apr 4 05:12:58 2012 UTC (8 years, 6 months ago) by william
File size: 2223 byte(s)
+ fix issues with selecting entries based on key press (a-z, 0-9)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.IO;
6 using EmuXPortal.Logging;
7
8 namespace EmuXPortal.Api
9 {
10 public class PlatformParser
11 {
12 private const string EMU_IGNORE_FILE = "emu_ignore.txt"; // if this file is present, that folder is ignored
13
14 public PlatformParser(string path)
15 {
16 List<string> romdirs = GetRomDirectories(path);
17 logger.WriteLine("Found {0} EMU Folders", romdirs.Count);
18 this.Platforms = GetEMUConfigFiles(romdirs);
19 this.Platforms.Sort();
20 }
21
22 public List<IEmuConfig> Platforms { get; private set; }
23
24 private List<string> GetRomDirectories(string path)
25 {
26 logger.WriteLine("Searching for EMU Folders in: {0}", path);
27 List<string> dirs = new List<string>();
28 foreach (string dir in Directory.GetDirectories(path))
29 {
30 bool ignore = false;
31 foreach (string file in Directory.GetFiles(dir))
32 {
33 FileInfo fi = new FileInfo(file);
34 if (fi.Name.ToLower() == EMU_IGNORE_FILE)
35 {
36 logger.WriteLine("\tIgnoreing EMU Folder: {0}", dir);
37 ignore = true;
38 break;
39 }
40 }
41 if (!ignore)
42 {
43 logger.WriteLine("\tAdding EMU Folder: {0}", dir);
44 dirs.Add(dir);
45 }
46 }
47 return dirs;
48 }
49
50 private List<IEmuConfig> GetEMUConfigFiles(List<string> romdirs)
51 {
52 List<IEmuConfig> emuconfigs = new List<IEmuConfig>();
53 logger.WriteLine("Reading EMU Config files");
54 foreach (string dir in romdirs)
55 {
56 IEmuConfig emuconfig = null;
57 emuconfig = EmuConfigLoader.Load(dir);
58 emuconfigs.Add(emuconfig);
59 }
60 logger.WriteLine("Finished Reading EMU Config files");
61 return emuconfigs;
62 }
63
64 }
65 }
66

  ViewVC Help
Powered by ViewVC 1.1.22