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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (show annotations) (download)
Tue Apr 3 21:54:58 2012 UTC (7 years, 10 months ago) by william
File size: 1564 byte(s)
initial commit for finding rom dirs

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 RomParser
11 {
12 /* Rom Parser format:
13 *
14 */
15
16 private const string EMU_IGNORE_FILE = "emu_ignore.txt"; // if this file is present, that folder is ignored
17
18 public RomParser(string path)
19 {
20 List<string> dirs = GetRomDirectories(path);
21 logger.WriteLine("Found {0} EMU Folders", dirs.Count);
22 }
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 }
51 }
52

  ViewVC Help
Powered by ViewVC 1.1.22