ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/EmuXPortal/trunk/EmuXPortal/Api/ConfigLoader.cs
(Generate patch)

Comparing trunk/EmuXPortal/Api/ConfigLoader.cs (file contents):
Revision 168 by william, Mon Aug 4 03:10:12 2014 UTC vs.
Revision 169 by william, Mon Aug 4 04:11:41 2014 UTC

# Line 24 | Line 24 | namespace EmuXPortal.Api
24      {
25          private static ConfigLoader loader = new ConfigLoader();
26          #region public class ConfigLoader : IConfigLoader
27 <        private class ConfigLoader : IConfigLoader, IConfig
27 >        internal class ConfigLoader : IConfigLoader, IConfig
28          {
29              private static string APP_PATH = Application.StartupPath;
30   #if CONFIGURATION_TESTING
# Line 34 | Line 34 | namespace EmuXPortal.Api
34              private static string CONFIG_FILE = "config.ini";
35              private static string FAVORITES_FILE = "favorites.ini";
36   #endif
37 <            private static string CONFIG_FILE_PATH = string.Format(@"{0}\", APP_PATH);
38 <            private static string CONFIG_FILE_INI = string.Format(@"{0}{1}", CONFIG_FILE_PATH, CONFIG_FILE);
39 <            private static string FAVORITES_FILE_INI = string.Format(@"{0}{1}", CONFIG_FILE_PATH, FAVORITES_FILE);
37 >            internal static string CONFIG_FILE_PATH = string.Format(@"{0}\", APP_PATH);
38 >            internal static string CONFIG_FILE_INI = string.Format(@"{0}{1}", CONFIG_FILE_PATH, CONFIG_FILE);
39 >            internal static string FAVORITES_FILE_INI = string.Format(@"{0}{1}", CONFIG_FILE_PATH, FAVORITES_FILE);
40              #region IConfigLoader Members
41 <            private bool LoadFavorites(logger log) { return LoadFavorites(log, FAVORITES_FILE_INI); }
42 <            private bool LoadFavorites(logger log, string ini)
41 >            internal static bool LoadFavorites(logger log) { return RomFavorite.LoadFavorites(log, FAVORITES_FILE_INI); }
42 >            internal static  bool LoadFavorites(logger log, string ini)
43              {
44 <                bool loaded = false;
45 <                try
46 <                {
47 <                    log.WriteLine("Loading Favorites: {0}", ini);
48 <                    FileInfo fi = new FileInfo(ini);
49 <                    if (!fi.Exists)
50 <                    {
51 <                        loaded = false;
52 <                        log.WriteLine("\tFailed to Load Favorites (file not found): {0}", ini);
53 <                        return loaded;
54 <                    }
55 <                    using (FileStream fs = new FileStream(ini, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
56 <                    {
57 <                        using (XmlReader reader = XmlReader.Create(fs))
58 <                        {
59 <                            //reader.ReadToFollowing("ROMPATH");
60 <                            //RomPath = reader.ReadElementContentAsString();
61 <                            //if (RomPath == "")
62 <                            //{
63 <                            //    log.WriteLine("\t\tROMPATH has not been configured...");
64 <                            //    MessageBox.Show("Please edit config.ini and update ROMPATH to point to your roms folder", "ROMPATH has not been configured", MessageBoxButtons.OK, MessageBoxIcon.Error);
65 <                            //    log.WriteLine("Terminating application...");
66 <                            //    Application.Exit();
67 <                            //}
68 <                            //log.WriteLine("\tROMPATH={0}", RomPath);
69 <                            //reader.ReadToFollowing("DISPLAYDEVICE");
70 <                            //DisplayDevice = reader.ReadElementContentAsString();
71 <                            //if (DisplayDevice == "")
72 <                            //{
73 <                            //    log.WriteLine("\t\tDISPLAYDEVICE was an empty string...using defaults: {0}", new DisplayHelper(log).PhysicalDisplayDevice.DeviceName);
74 <                            //    DisplayDevice = new DisplayHelper(log).PhysicalDisplayDevice.DeviceName;
75 <                            //}
76 <                            //log.WriteLine("\tDISPLAYDEVICE={0}", DisplayDevice);
77 <                        }
78 <                    }
79 <                    log.WriteLine("Loaded Favorites: {0}", ini);
80 <                    loaded = true;
81 <
82 <                }
83 <                catch (Exception ex)
84 <                {
85 <                    log.WriteLine("\tFailed to Load Favorites: {0}", ini);
86 <                    Console.WriteLine(ex.ToString());
87 <                    log.WriteLine("Error: {0}", ex.ToString());
88 <                    loaded = false;
89 <                }
90 <                return loaded;
44 >                return RomFavorite.LoadFavorites(log, ini);
45              }
46              public bool LoadConfig(logger log) { return LoadConfig(log, CONFIG_FILE_INI); }
47              public bool LoadConfig(logger log, string ini)
# Line 103 | Line 57 | namespace EmuXPortal.Api
57                          log.WriteLine("\tFailed to Load Config (file not found): {0}", ini);
58                          return loaded;
59                      }
60 <                    using (FileStream fs = new FileStream(ini, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
60 >                    using (FileStream fs = new FileStream(ini, FileMode.Open, FileAccess.Read, FileShare.Read))
61                      {
62                          using (XmlReader reader = XmlReader.Create(fs))
63                          {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines