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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (hide annotations) (download)
Wed Apr 4 01:32:37 2012 UTC (8 years, 11 months ago) by william
File size: 2187 byte(s)
+ add entries for platforms
+ add entries for roms
+ add key events

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

  ViewVC Help
Powered by ViewVC 1.1.22